Skip to content

docs(format): define index dataset_version and fragment_bitmap rules - #10090

Draft
wjones127 wants to merge 2 commits into
lance-format:mainfrom
wjones127:claude/lance-index-system-doc-6a99e7
Draft

wjones127 wants to merge 2 commits into
lance-format:mainfrom
wjones127:claude/lance-index-system-doc-6a99e7

Conversation

@wjones127

@wjones127 wjones127 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The index spec never defined IndexMetadata.dataset_version, and fragment_bitmap was described only as "fragments covered". Different code paths treat them inconsistently: as build version or remap watermark, and as old or new fragment ids under a fragment reuse index (FRI). This PR writes down the contract:

  • dataset_version is a watermark. Overlays committed after it, and FRI entries stamped at or after it, are not reflected in the segment's data. It must never exceed W, the version just before the first such change to a covered fragment. Any value at or below the version the data was read from is valid.
  • fragment_bitmap may hold old or new fragment ids under an FRI. Released writers already persist FRI-mapped bitmaps on every commit. dataset_version, not the bitmap, decides the address space of the index data.
  • Writers either keep a conservative version or stamp their read version after catching up overlays and FRI entries. They never restamp on retry.
  • Rules for live coverage (including tagged FRI histories), staged segments committed later, empty segments, and compaction that folds overlays.
  • table.proto comment updates for IndexMetadata.dataset_version, fragment_bitmap, and the FRI Version.dataset_version stamp. No wire changes.

This describes the intended contract. Known places where the code diverges: #9861, #10091, #10092, #10093, #10094, #10095, #10096, #10097, #10098.

Merge Risk

Door: two-way. Documentation and proto comments only; no wire or behavior change.
Blast Radius: format spec (requires a PMC vote).

🤖 Generated with Claude Code

@github-actions github-actions Bot added A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). documentation Improvements or additions to documentation labels Oct 17, 2026
wjones127 pushed a commit that referenced this pull request Oct 17, 2026
…t is empty (#10107)

Closes #10097.

When every segment of an index has empty live coverage,
`retain_relevant_indices` keeps a single segment as the index
definition. It picked the lowest `dataset_version`, but that's a
watermark rather than a creation time (merges take the minimum of their
sources, remaps raise it), so it could keep a newer segment and lose the
earliest `created_at`.

This sorts the all-empty segments by `created_at` instead, as #10097 /
#10090 describe: segments without a `created_at` go after those with
one, and ties fall back to the lowest `dataset_version`. Segments that
all lack `created_at` behave exactly as before.

Testing: added
`test_retain_multiple_empty_indices_keeps_earliest_created` (fails on
main, passes here). `cargo test -p lance-table --lib` passes, and `cargo
fmt` / `cargo clippy -p lance-table --tests` show nothing new.

I used an AI coding assistant to help write this change and the test; I
reviewed the diff and ran the tests above.
wjones127 pushed a commit that referenced this pull request Oct 17, 2026
…lay compaction (#10109)

Closes #10091.

On a table without stable row ids, a compaction with `defer_index_remap:
true` that folds a data overlay on an indexed field left the index
covering the compacted rows with their pre-overlay values.
`prune_overlay_stale_fields_from_indices` only removed the group's new
fragment ids from a stale index's bitmap, but on the deferred path the
bitmap still holds the old ids (the fragment reuse index translates them
at load time), so nothing was removed and `val = <old value>` kept
matching.

This removes both the old and the new fragment ids of the group from
stale indices, which is the second option the issue gives (per #10090).
On the eager path the old ids are already gone, so that path behaves as
before. Tagged FRI tables still refuse this compaction, so they aren't
affected.

Testing: `test_overlay_compaction_reconciles_stale_index` now runs with
both eager and deferred remap; the deferred case fails on main (the
index still covers the compacted fragment) and passes here.
`test_prune_overlay_stale_fields_from_indices` gained a stale index that
still covers the old fragment id. `cargo test -p lance-table --lib`
passes, as do the `overlay`, `dataset::optimize` and
`dataset::index::frag_reuse` tests in `lance`. `cargo fmt --all` is
clean and `cargo clippy -p lance -p lance-table --lib --tests -- -D
warnings` passes; I didn't run the full-workspace clippy.

This touches the same function as #10108 (which changes how stale fields
are matched, not which fragment ids are removed), so whichever lands
second needs a small rebase.

I used an AI coding assistant to help write this change and the tests; I
reviewed the diff and ran the checks above.

Co-authored-by: ump45nose <[email protected]>
wjones127 pushed a commit that referenced this pull request Oct 23, 2026
Closes #10092.

Three index maintenance paths decided whether an index depends on a
field by exact field id: the overlay check in `remap_index` /
`remap_index_tagged`, `prune_overlay_stale_fields_from_indices`, and the
untagged branch of `withdraw_in_place_rewrites`. A change reported
against a struct `s` then left coverage on an index over `s.x` (and a
change to `s.y` left an index over `s` alone), so the index could keep
serving the old values.

These paths now use `field_affects_index`, the same subtree rule
`fresh_fragments` and the overlay staleness checks already use:

- the remap overlay checks call `overlay_affects_index`;
- `prune_overlay_stale_fields_from_indices` takes the schema and matches
overlaid fields by subtree;
- the untagged branch of `withdraw_in_place_rewrites` drops the
rewritten fragment from every index that depends on a rewritten field.
The tagged branch is unchanged.

`IndexMetadata.fields` already holds the covering fields, so this
matches the `fields ∪ covering_fields` subtree rule from #10090. Like
the issue says, I haven't confirmed that a current writer reports only
the parent id; this just makes the three paths agree with the rest.

Testing: added `test_prune_overlay_stale_fields_matches_nested_fields`
and `test_untagged_in_place_rewrite_withdraws_nested_fields` (parent
change vs. child index, child change vs. parent index, unrelated field).
`cargo test -p lance-table --lib` passes, as do the
`dataset::optimize::remapping` (49) and `overlay` (206) tests in
`lance`. `cargo fmt --all` is clean, `cargo clippy -p lance --lib -- -D
warnings` is clean, and `cargo clippy -p lance-table --tests` shows
nothing in the touched code (with `-D warnings` it stops on existing
dead-code warnings in `lance-io`'s throttle module). I didn't run the
full-workspace clippy.

I used an AI coding assistant to help write this change and the tests; I
reviewed the diff and ran the checks above.

---------

Co-authored-by: ump45nose <[email protected]>
Comment thread docs/src/format/index/index.md Outdated
Comment on lines +97 to +98
fragment as of this dataset version. For indices whose results are row addresses, that includes
row addresses. A consequence is that the bitmap does not determine which address space the index

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

issue: I find this sentence confusing:

For indices whose results are row addresses, that includes row addresses.

Could you describe more concretely what this means? Does it just mean the row_addresses recorded in the index are what the rows addresses were at that dataset version, and if they've been moved they need to be remapped by the FRI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what it meant. Reworded: the stored row addresses are the ones the rows had at dataset_version, and if a later compaction moved them they must be remapped through the FRI entries that record it.

Comment thread docs/src/format/index/index.md Outdated
Comment on lines +97 to +98
fragment as of this dataset version. For indices whose results are row addresses, that includes
row addresses. A consequence is that the bitmap does not determine which address space the index

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

issue: this is also confusing.

consequence is that the bitmap does not determine which address space the index
data is in; dataset_version does...

What does "address space" mean here? I would have guessed it's _rowid vs _rowaddr, but that's not determined by dataset_version, so I think you mean something else.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I meant whether the stored addresses are pre- or post-compaction, not _rowid vs _rowaddr. Dropped the term; it now says the bitmap can't tell a reader whether the stored row addresses still need FRI remapping, and only dataset_version can.

Comment thread docs/src/format/index/index.md Outdated
- the `dataset_version` of each FRI version entry added after B whose old or new fragments
intersect the segment's `fragment_bitmap`.

If there are none, W is the current dataset version. A segment's `dataset_version` must never

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

question: "If there are none" what? FRI? Overlays? Either? Could you be more specific here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now reads "If no such merge-on-read update or FRI version entry exists".

Comment thread docs/src/format/index/index.md Outdated
Comment on lines +117 to +118
entries the segment still needs. Any value at or below B is valid. A lower value may cause more
rows to be treated as stale, but never yields wrong results.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

suggestion: is there a mermaid diagram we could put here that would illustrate the concept?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a mermaid version timeline with a worked example (B=3, overlay at v5, compaction at v7 with FRI stamp 6, so W=4), marking valid and invalid stamps.

Comment thread docs/src/format/index/index.md Outdated
Comment on lines +176 to +177
- **Keep a conservative version.** Use a value no greater than the B of every source segment the
new segment's data came from.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

suggestion: no one who skipped to this section will no what B is here. Redefine it.

Also, is this a min of all source segments? Or max? Maybe give an example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Redefined B and R at the top of the section. It's the min: a conservative stamp must be at or below the smallest B among the sources. Added an example: merging segments built from v5 and v9 may keep any value up to 5.

Comment thread docs/src/format/index/index.md Outdated
Comment on lines +180 to +183
- Each overlay on an indexed field is either folded into the index data or its fragment is
removed from the `fragment_bitmap`. Folding must be idempotent: applying an overlay the
index already reflects must leave the index unchanged.
- Each FRI version entry is applied to the index data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thought: I wonder if we can come up with a term for fragment data updates that captures the overlays and similar merge-on-read changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adopted "merge-on-read update", defined in the coverage section with data overlays as the current kind, and used it throughout the write and compaction rules and the proto comment.

Comment thread docs/src/format/index/index.md Outdated
Comment on lines +201 to +202
when it was built separately and committed later. The manifest at that `dataset_version` need not
be an ancestor of the version the commit is built on, for example after a restore. Before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

question: This is strange fact, and I almost want to leave it out and unintended. There a reason to keep this?

The manifest at that dataset_version need not be an ancestor of the version the commit is built on, for example after a restore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No strong reason, since the diff rule that follows already covers a restore. Removed the sentence and kept the rule.

Define merge-on-read updates, explain row-address remapping without the
"address space" term, add a version timeline example, redefine B in the
write rules, and drop the restore ancestry note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs documentation Improvements or additions to documentation format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant