Skip to content

sync flatbuffers schema with upstream icechunk#1

Merged
Shane98c merged 2 commits intomainfrom
sync-flatbuffers-schema
Mar 30, 2026
Merged

sync flatbuffers schema with upstream icechunk#1
Shane98c merged 2 commits intomainfrom
sync-flatbuffers-schema

Conversation

@Shane98c
Copy link
Copy Markdown
Collaborator

Syncs FlatBuffer schemas and generated code with earth-mover/icechunk@0488686 which reordered manifest_files_v2/extra fields in the Snapshot table.

  • Regenerated TypeScript FlatBuffer classes
  • Updated snapshot parser to read manifest_files_v2 with v1 fallback
  • Fixed snapshot test to use migrated repo fixtures (native v2 snapshots no longer embed manifest file references)
  • Added regression test for shape_v2 parsing on native v2 arrays

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a v2 format in the FlatBuffers schema, including new generated classes and updated parsers for snapshots and array node data. It adds "extra" fields for extensibility and implements backward compatibility by falling back to v1 structures when v2 fields are absent. Feedback was provided regarding code duplication in the manifest file parsing logic within the snapshot parser.

Comment on lines 84 to 113
const manifestFiles: ManifestFileInfo[] = [];
for (let i = 0; i < manifestFilesLength; i++) {
const fbsMfi = fbsSnapshot.manifestFiles(i);
if (fbsMfi) {
const mfiIdObj = fbsMfi.id();
if (!mfiIdObj) throw new Error("ManifestFileInfo missing id");
manifestFiles.push({
id: asObjectId12(readId12(mfiIdObj.bb!, mfiIdObj.bb_pos)),
sizeBytes: Number(fbsMfi.sizeBytes()),
numChunkRefs: fbsMfi.numChunkRefs(),
});
const v2Length = fbsSnapshot.manifestFilesV2Length();
if (v2Length > 0) {
for (let i = 0; i < v2Length; i++) {
const fbsMfi = fbsSnapshot.manifestFilesV2(i);
if (fbsMfi) {
const mfiIdObj = fbsMfi.id();
if (!mfiIdObj) throw new Error("ManifestFileInfoV2 missing id");
manifestFiles.push({
id: asObjectId12(readId12(mfiIdObj.bb!, mfiIdObj.bb_pos)),
sizeBytes: Number(fbsMfi.sizeBytes()),
numChunkRefs: fbsMfi.numChunkRefs(),
});
}
}
} else {
const v1Length = fbsSnapshot.manifestFilesLength();
for (let i = 0; i < v1Length; i++) {
const fbsMfi = fbsSnapshot.manifestFiles(i);
if (fbsMfi) {
const mfiIdObj = fbsMfi.id();
if (!mfiIdObj) throw new Error("ManifestFileInfo missing id");
manifestFiles.push({
id: asObjectId12(readId12(mfiIdObj.bb!, mfiIdObj.bb_pos)),
sizeBytes: Number(fbsMfi.sizeBytes()),
numChunkRefs: fbsMfi.numChunkRefs(),
});
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's significant code duplication in the logic for parsing v1 and v2 manifest files. This can be refactored to be more concise and improve maintainability by determining which version to use upfront and then using a single loop.

  const manifestFiles: ManifestFileInfo[] = [];
  const v2Length = fbsSnapshot.manifestFilesV2Length();
  const useV2 = v2Length > 0;
  const length = useV2 ? v2Length : fbsSnapshot.manifestFilesLength();

  for (let i = 0; i < length; i++) {
    const fbsMfi = useV2
      ? fbsSnapshot.manifestFilesV2(i)
      : fbsSnapshot.manifestFiles(i);

    if (fbsMfi) {
      const mfiIdObj = fbsMfi.id();
      if (!mfiIdObj) {
        throw new Error(`ManifestFileInfo${useV2 ? "V2" : ""} missing id`);
      }
      manifestFiles.push({
        id: asObjectId12(readId12(mfiIdObj.bb!, mfiIdObj.bb_pos)),
        sizeBytes: Number(fbsMfi.sizeBytes()),
        numChunkRefs: fbsMfi.numChunkRefs(),
      });
    }
  }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easier to keep these separate in case things diverge further in the future.

@Shane98c Shane98c merged commit 86a7a99 into main Mar 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant