From 4057d5549a31ced0b5a3ea3f652c62d68cd41527 Mon Sep 17 00:00:00 2001 From: geruh Date: Thu, 5 Nov 2026 14:32:55 -0800 Subject: [PATCH 1/7] feat(format): add durable index row bindings --- docs/src/format/index/.pages | 1 + .../format/index/durable_row_references.md | 121 ++++++++++++++++ docs/src/format/index/index.md | 6 + protos/table.proto | 53 +++++++ rust/lance-table/src/format/index.rs | 26 ++++ rust/lance-table/src/pb/lance.table.rs | 129 ++++++++++++++++++ 6 files changed, 336 insertions(+) create mode 100644 docs/src/format/index/durable_row_references.md diff --git a/docs/src/format/index/.pages b/docs/src/format/index/.pages index 1880de92cf6..56bfb7b04c7 100644 --- a/docs/src/format/index/.pages +++ b/docs/src/format/index/.pages @@ -1,6 +1,7 @@ title: Index Formats nav: - Overview: index.md + - Durable row references: durable_row_references.md - Scalar Indices: scalar - Vector Indices: vector - System Indices: system diff --git a/docs/src/format/index/durable_row_references.md b/docs/src/format/index/durable_row_references.md new file mode 100644 index 00000000000..dd8d5d301c7 --- /dev/null +++ b/docs/src/format/index/durable_row_references.md @@ -0,0 +1,121 @@ +# Durable index row references + +## Overview + +Index files are immutable once written, while Lance assigns fragment IDs and new stable row IDs when it builds a manifest. If an index is written before those IDs are final, a concurrent append can claim the expected IDs while the prepared index file still contains the earlier ones. Updating `fragment_bitmap` alone does not change the references stored inside the file. + +`IndexMetadata` has an optional `row_binding` field that maps the references stored in an index segment to their committed IDs. A commit retry updates the binding in metadata and leaves the index files unchanged. + +Whether a segment carries a binding depends on what its files store: + +- An index written with committed identities has no binding. +- An index built with local references keeps its binding even if no concurrent writer commits first. +- A compaction or index rewrite drops the binding once the replacement files store committed identities. + +Publishing an append and its index together is one use of this contract, and any writer that prepares index files before commit follows the same rules. + +## Row references + +**Physical row addresses** pack a fragment ID and a row offset into a 64 bit integer: + +```text +row_address = (fragment_id << 32) | row_offset +``` + +Compaction can move a row to a new address, and the [Fragment Reuse Index](system/frag_reuse.md) translates that address at read time without modifying the index file. + +**Stable row IDs** track logical rows across compaction. Once committed, a row's stable ID never changes, though IDs assigned to staged rows can shift if another writer advances `next_row_id` before commit. See [row ID assignment](../table/row_id_lineage.md#row-id-assignment). + +An index segment can store either kind of reference. Some indexes store physical addresses even when stable row IDs are enabled. A BTree on `_rowid` stores stable row IDs as keys and physical addresses as values, so a single segment can need both bindings. + +## Row binding + +`row_binding` is field 14 on `IndexMetadata`. It has separate fields for physical addresses and stable row IDs, and each field uses a `oneof` so future encodings can be added alongside the initial ones. + +### Fragment array + +For physical addresses, the index file stores fragment ordinals starting at `0`. Each ordinal is a position in that segment's array of committed fragment IDs: + +```text +Index file: (0, 5) (1, 8) (2, 3) +Committed fragments: [42, 47, 53] +``` + +Here, `(1, 8)` resolves to `(47, 8)` with the row offset unchanged. + +The writer fixes the ordinal order when it builds the index. A commit retry can replace the committed fragment IDs in the array, but it must not reorder the positions. Each segment has its own array, so two segments can both use ordinal `0`. + +`fragment_bitmap` records the committed fragments the segment currently covers, while the array records how to decode references inside the index files. Removing a fragment from `fragment_bitmap` must not remove or reorder array entries. Every fragment listed in `fragment_bitmap` must have a valid array entry. + +### Stable row ID spans + +Indexes such as NGram store stable row IDs directly, so a fragment ID mapping does not change their references. + +For a contiguous run of newly assigned row IDs, one span maps the starting ID stored in the index to the starting ID assigned at commit: + +```text +stored_base = 10 +committed_base = 15 +count = 10 + +Stored: 10..19 +Committed: 15..24 +``` + +Stored row ID `12` resolves to `17`. A segment can hold several spans, including spans with different offsets. + +Caller supplied row IDs that are already final need no span when every stored row ID in the segment is already committed. Multiple spans (including spans of length one) can represent a noncontiguous caller supplied prefix alongside an assigned tail that shifted on rebase. A writer that cannot encode its stored row IDs as spans must reject the commit. + +When a stable row ID binding is present, every stored row ID in the segment must match exactly one span, and any unmapped ID is an error. + +### Row IDs stored as search keys + +In most indexes, search keys are column values and the binding only translates the row references returned by the index. + +A BTree on `_rowid` (field `-3`) is different because it stores stable row IDs as search keys and physical addresses as values. To read a bound `_rowid` BTree, the reader must translate query predicates into the stored row ID space before searching, and then resolve the returned physical addresses. Range queries across multiple spans may require separate lookups for each span. Writers must reject indexes with provisional `_rowid` keys until that predicate translation is supported. See [Stable Row ID Reverse Lookup](scalar/btree.md#stable-row-id-reverse-lookup). + +## Format rules + +* **Build:** When writing an index with local references, the writer records the fragment array order and any provisional row ID spans required to decode the files. +* **Commit:** Manifest construction assigns the committed IDs and writes `row_binding` with the data and the index in one commit. A retry updates `row_binding` without rewriting the index files. +* **Read:** Readers translate local references before using them as dataset identities. Physical addresses resolve through the fragment array before Fragment Reuse Index translation, and stable row IDs resolve through the row ID spans. A reader must never treat a stable row ID as a physical address. +* **Coverage:** `fragment_bitmap` stores committed fragment IDs for query planning. An ordinal in an index file is never treated as a committed fragment ID. +* **Maintenance:** An operation that keeps index files keeps their `row_binding`. An operation that rewrites index files resolves the old references and writes either committed identities (with no binding) or a new binding. Compaction must preserve the binding, rewrite the index with committed identities, or safely drop the index, and if none of these is supported it must reject the operation before commit. +* **Validation:** If `row_binding` is absent, the index files already store committed identities. If `row_binding` is present, an empty message, an unknown `oneof` variant, an out of bounds ordinal, an invalid span, or spans that overlap in the stored or committed ID space is an error. Readers must reject any binding they cannot interpret rather than fall back to the raw stored number. +* **Compatibility:** A dataset with a bound index segment sets both a reader feature flag and a writer feature flag so implementations that do not recognize the flag refuse the dataset. Clones and other metadata copies that keep the index files must keep the binding and both flags. Writers must not emit field 14 until the feature flag bit is assigned. See [feature flags](../table/versioning.md#feature-flags). + +## Protobuf + +```protobuf +%%% proto.message.IndexRowBinding %%% +``` + +```protobuf +%%% proto.message.FragmentBinding %%% +``` + +```protobuf +%%% proto.message.FragmentArray %%% +``` + +```protobuf +%%% proto.message.StableRowBinding %%% +``` + +```protobuf +%%% proto.message.RowIdSpans %%% +``` + +```protobuf +%%% proto.message.RowIdSpan %%% +``` + +## See also + +* [Index format](index.md) +* [Row addresses and stable row IDs](../table/row_id_lineage.md) +* [Fragment Reuse Index](system/frag_reuse.md) +* [Feature flags](../table/versioning.md#feature-flags) +* [Transaction V2](https://github.com/lance-format/lance/pull/7954) +* [Append and index in one commit](https://github.com/lance-format/lance/issues/10386) +* [Staged transactions](https://github.com/lance-format/lance/pull/10722) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index c1e4448deab..21b006ae212 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -342,3 +342,9 @@ logical identifier that remains constant even when rows are moved during compact This feature is currently experimental. Performance evaluation is ongoing to determine when the tradeoff is worthwhile. + +## Durable row references + +Index files are immutable once written. Fragment IDs, and stable row IDs for new rows, are assigned when the commit builds the manifest. A concurrent commit can change those IDs after the index file has been written. + +[Durable index row references](durable_row_references.md) defines an optional `row_binding` on `IndexMetadata`. A retry replaces the binding and keeps the index files. Writers must not emit the field until its feature flag bit is assigned. diff --git a/protos/table.proto b/protos/table.proto index 6b99dbbfb18..f941656ee81 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -459,6 +459,59 @@ message IndexMetadata { * inherit entries automatically. Requires writer flag 1 << 17 while nonempty. */ map metadata = 13; + + /* Resolves references stored in index files to committed IDs. + * Absent when the files already store committed IDs. + * Requires reader and writer feature flags. + */ + optional IndexRowBinding row_binding = 14; +} + +/* A segment may bind fragment addresses, stable row IDs, or both. + * Readers reject an empty binding and an encoding they do not recognize. + */ +message IndexRowBinding { + optional FragmentBinding fragments = 1; + optional StableRowBinding row_ids = 2; +} + +message FragmentBinding { + oneof encoding { + FragmentArray array = 1; + } +} + +/* Fragment ordinal i resolves to committed_fragment_ids[i]. + * The list is nonempty and its entries are unique. + * Entries remain in place when index coverage shrinks. + */ +message FragmentArray { + repeated uint32 committed_fragment_ids = 1; +} + +message StableRowBinding { + oneof encoding { + RowIdSpans spans = 1; + } +} + +/* Every stored row ID covered by this binding matches exactly one span. + * An empty list is corrupt. + */ +message RowIdSpans { + repeated RowIdSpan spans = 1; +} + +/* Maps [stored_base, stored_base + count) to + * [committed_base, committed_base + count). + * count must be greater than zero. + * Spans must not overlap in the stored ID space or the committed ID space. + * A span must not overflow uint64. + */ +message RowIdSpan { + uint64 stored_base = 1; + uint64 committed_base = 2; + uint64 count = 3; } // Metadata about a single file within an index segment. diff --git a/rust/lance-table/src/format/index.rs b/rust/lance-table/src/format/index.rs index 8c71c6fa567..3db3dd12f71 100644 --- a/rust/lance-table/src/format/index.rs +++ b/rust/lance-table/src/format/index.rs @@ -743,6 +743,14 @@ impl IndexMetadata { }) .transpose()?; + // The files may contain local ordinals or provisional row ids. Dropping + // the binding here would publish those numbers as committed identities. + if proto.row_binding.is_some() { + return Err(Error::not_supported( + "index segment has a row binding, which this build does not apply", + )); + } + Ok(Self { uuid: proto.uuid.as_ref().map(Uuid::try_from).ok_or_else(|| { Error::invalid_input("uuid field does not exist in Index metadata".to_string()) @@ -816,6 +824,7 @@ impl From<&IndexMetadata> for pb::IndexMetadata { created_at: idx.created_at.map(|dt| dt.timestamp_millis() as u64), base_id: idx.base_id, files, + row_binding: None, } } } @@ -973,6 +982,23 @@ mod tests { assert!(err.to_string().contains("created_at"), "got: {err}"); } + #[test] + fn test_index_metadata_rejects_a_row_binding() { + let mut proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); + proto.row_binding = Some(pb::IndexRowBinding { + fragments: Some(pb::FragmentBinding { + encoding: Some(pb::fragment_binding::Encoding::Array(pb::FragmentArray { + committed_fragment_ids: vec![42, 47], + })), + }), + row_ids: None, + }); + + let err = IndexMetadata::try_from(proto).unwrap_err(); + assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); + assert!(err.to_string().contains("row binding"), "got: {err}"); + } + #[test] fn test_index_metadata_created_at_roundtrip() { let mut metadata = index_metadata_with(vec![0], vec![]); diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index 9fec036c8cf..ef1a310ac1c 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1261,6 +1261,11 @@ pub struct IndexMetadata { #[prost(map = "string, string", tag = "13")] pub metadata: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, + /// Resolves references stored in index files to committed IDs. + /// Absent when the files already store committed IDs. + /// Requires reader and writer feature flags. + #[prost(message, optional, tag = "14")] + pub row_binding: ::core::option::Option, } impl ::prost::Name for IndexMetadata { const NAME: &'static str = "IndexMetadata"; @@ -1272,6 +1277,130 @@ impl ::prost::Name for IndexMetadata { "/lance.table.IndexMetadata".into() } } +/// A segment may bind fragment addresses, stable row IDs, or both. +/// Readers reject an empty binding and an encoding they do not recognize. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IndexRowBinding { + #[prost(message, optional, tag = "1")] + pub fragments: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub row_ids: ::core::option::Option, +} +impl ::prost::Name for IndexRowBinding { + const NAME: &'static str = "IndexRowBinding"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.IndexRowBinding".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.IndexRowBinding".into() + } +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FragmentBinding { + #[prost(oneof = "fragment_binding::Encoding", tags = "1")] + pub encoding: ::core::option::Option, +} +/// Nested message and enum types in `FragmentBinding`. +pub mod fragment_binding { + #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] + pub enum Encoding { + #[prost(message, tag = "1")] + Array(super::FragmentArray), + } +} +impl ::prost::Name for FragmentBinding { + const NAME: &'static str = "FragmentBinding"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.FragmentBinding".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.FragmentBinding".into() + } +} +/// Fragment ordinal i resolves to committed_fragment_ids\[i\]. +/// The list is nonempty and its entries are unique. +/// Entries remain in place when index coverage shrinks. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct FragmentArray { + #[prost(uint32, repeated, tag = "1")] + pub committed_fragment_ids: ::prost::alloc::vec::Vec, +} +impl ::prost::Name for FragmentArray { + const NAME: &'static str = "FragmentArray"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.FragmentArray".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.FragmentArray".into() + } +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StableRowBinding { + #[prost(oneof = "stable_row_binding::Encoding", tags = "1")] + pub encoding: ::core::option::Option, +} +/// Nested message and enum types in `StableRowBinding`. +pub mod stable_row_binding { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Encoding { + #[prost(message, tag = "1")] + Spans(super::RowIdSpans), + } +} +impl ::prost::Name for StableRowBinding { + const NAME: &'static str = "StableRowBinding"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.StableRowBinding".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.StableRowBinding".into() + } +} +/// Every stored row ID covered by this binding matches exactly one span. +/// An empty list is corrupt. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RowIdSpans { + #[prost(message, repeated, tag = "1")] + pub spans: ::prost::alloc::vec::Vec, +} +impl ::prost::Name for RowIdSpans { + const NAME: &'static str = "RowIdSpans"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.RowIdSpans".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.RowIdSpans".into() + } +} +/// Maps [stored_base, stored_base + count) to +/// [committed_base, committed_base + count). +/// count must be greater than zero. +/// Spans must not overlap in the stored ID space or the committed ID space. +/// A span must not overflow uint64. +#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] +pub struct RowIdSpan { + #[prost(uint64, tag = "1")] + pub stored_base: u64, + #[prost(uint64, tag = "2")] + pub committed_base: u64, + #[prost(uint64, tag = "3")] + pub count: u64, +} +impl ::prost::Name for RowIdSpan { + const NAME: &'static str = "RowIdSpan"; + const PACKAGE: &'static str = "lance.table"; + fn full_name() -> ::prost::alloc::string::String { + "lance.table.RowIdSpan".into() + } + fn type_url() -> ::prost::alloc::string::String { + "/lance.table.RowIdSpan".into() + } +} /// Metadata about a single file within an index segment. #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct IndexFile { From 930f54d7b5db3445fc5eb0ddf7b8e7c5be311f38 Mon Sep 17 00:00:00 2001 From: geruh Date: Thu, 5 Nov 2026 21:55:23 -0800 Subject: [PATCH 2/7] feat(format): define durable index fragment bindings --- docs/src/format/index/.pages | 1 - .../format/index/durable_row_references.md | 121 ---------------- docs/src/format/index/index.md | 61 +++++++- protos/table.proto | 58 ++------ rust/lance-table/src/format/index.rs | 57 ++++++-- rust/lance-table/src/pb/lance.table.rs | 137 ++---------------- 6 files changed, 123 insertions(+), 312 deletions(-) delete mode 100644 docs/src/format/index/durable_row_references.md diff --git a/docs/src/format/index/.pages b/docs/src/format/index/.pages index 56bfb7b04c7..1880de92cf6 100644 --- a/docs/src/format/index/.pages +++ b/docs/src/format/index/.pages @@ -1,7 +1,6 @@ title: Index Formats nav: - Overview: index.md - - Durable row references: durable_row_references.md - Scalar Indices: scalar - Vector Indices: vector - System Indices: system diff --git a/docs/src/format/index/durable_row_references.md b/docs/src/format/index/durable_row_references.md deleted file mode 100644 index dd8d5d301c7..00000000000 --- a/docs/src/format/index/durable_row_references.md +++ /dev/null @@ -1,121 +0,0 @@ -# Durable index row references - -## Overview - -Index files are immutable once written, while Lance assigns fragment IDs and new stable row IDs when it builds a manifest. If an index is written before those IDs are final, a concurrent append can claim the expected IDs while the prepared index file still contains the earlier ones. Updating `fragment_bitmap` alone does not change the references stored inside the file. - -`IndexMetadata` has an optional `row_binding` field that maps the references stored in an index segment to their committed IDs. A commit retry updates the binding in metadata and leaves the index files unchanged. - -Whether a segment carries a binding depends on what its files store: - -- An index written with committed identities has no binding. -- An index built with local references keeps its binding even if no concurrent writer commits first. -- A compaction or index rewrite drops the binding once the replacement files store committed identities. - -Publishing an append and its index together is one use of this contract, and any writer that prepares index files before commit follows the same rules. - -## Row references - -**Physical row addresses** pack a fragment ID and a row offset into a 64 bit integer: - -```text -row_address = (fragment_id << 32) | row_offset -``` - -Compaction can move a row to a new address, and the [Fragment Reuse Index](system/frag_reuse.md) translates that address at read time without modifying the index file. - -**Stable row IDs** track logical rows across compaction. Once committed, a row's stable ID never changes, though IDs assigned to staged rows can shift if another writer advances `next_row_id` before commit. See [row ID assignment](../table/row_id_lineage.md#row-id-assignment). - -An index segment can store either kind of reference. Some indexes store physical addresses even when stable row IDs are enabled. A BTree on `_rowid` stores stable row IDs as keys and physical addresses as values, so a single segment can need both bindings. - -## Row binding - -`row_binding` is field 14 on `IndexMetadata`. It has separate fields for physical addresses and stable row IDs, and each field uses a `oneof` so future encodings can be added alongside the initial ones. - -### Fragment array - -For physical addresses, the index file stores fragment ordinals starting at `0`. Each ordinal is a position in that segment's array of committed fragment IDs: - -```text -Index file: (0, 5) (1, 8) (2, 3) -Committed fragments: [42, 47, 53] -``` - -Here, `(1, 8)` resolves to `(47, 8)` with the row offset unchanged. - -The writer fixes the ordinal order when it builds the index. A commit retry can replace the committed fragment IDs in the array, but it must not reorder the positions. Each segment has its own array, so two segments can both use ordinal `0`. - -`fragment_bitmap` records the committed fragments the segment currently covers, while the array records how to decode references inside the index files. Removing a fragment from `fragment_bitmap` must not remove or reorder array entries. Every fragment listed in `fragment_bitmap` must have a valid array entry. - -### Stable row ID spans - -Indexes such as NGram store stable row IDs directly, so a fragment ID mapping does not change their references. - -For a contiguous run of newly assigned row IDs, one span maps the starting ID stored in the index to the starting ID assigned at commit: - -```text -stored_base = 10 -committed_base = 15 -count = 10 - -Stored: 10..19 -Committed: 15..24 -``` - -Stored row ID `12` resolves to `17`. A segment can hold several spans, including spans with different offsets. - -Caller supplied row IDs that are already final need no span when every stored row ID in the segment is already committed. Multiple spans (including spans of length one) can represent a noncontiguous caller supplied prefix alongside an assigned tail that shifted on rebase. A writer that cannot encode its stored row IDs as spans must reject the commit. - -When a stable row ID binding is present, every stored row ID in the segment must match exactly one span, and any unmapped ID is an error. - -### Row IDs stored as search keys - -In most indexes, search keys are column values and the binding only translates the row references returned by the index. - -A BTree on `_rowid` (field `-3`) is different because it stores stable row IDs as search keys and physical addresses as values. To read a bound `_rowid` BTree, the reader must translate query predicates into the stored row ID space before searching, and then resolve the returned physical addresses. Range queries across multiple spans may require separate lookups for each span. Writers must reject indexes with provisional `_rowid` keys until that predicate translation is supported. See [Stable Row ID Reverse Lookup](scalar/btree.md#stable-row-id-reverse-lookup). - -## Format rules - -* **Build:** When writing an index with local references, the writer records the fragment array order and any provisional row ID spans required to decode the files. -* **Commit:** Manifest construction assigns the committed IDs and writes `row_binding` with the data and the index in one commit. A retry updates `row_binding` without rewriting the index files. -* **Read:** Readers translate local references before using them as dataset identities. Physical addresses resolve through the fragment array before Fragment Reuse Index translation, and stable row IDs resolve through the row ID spans. A reader must never treat a stable row ID as a physical address. -* **Coverage:** `fragment_bitmap` stores committed fragment IDs for query planning. An ordinal in an index file is never treated as a committed fragment ID. -* **Maintenance:** An operation that keeps index files keeps their `row_binding`. An operation that rewrites index files resolves the old references and writes either committed identities (with no binding) or a new binding. Compaction must preserve the binding, rewrite the index with committed identities, or safely drop the index, and if none of these is supported it must reject the operation before commit. -* **Validation:** If `row_binding` is absent, the index files already store committed identities. If `row_binding` is present, an empty message, an unknown `oneof` variant, an out of bounds ordinal, an invalid span, or spans that overlap in the stored or committed ID space is an error. Readers must reject any binding they cannot interpret rather than fall back to the raw stored number. -* **Compatibility:** A dataset with a bound index segment sets both a reader feature flag and a writer feature flag so implementations that do not recognize the flag refuse the dataset. Clones and other metadata copies that keep the index files must keep the binding and both flags. Writers must not emit field 14 until the feature flag bit is assigned. See [feature flags](../table/versioning.md#feature-flags). - -## Protobuf - -```protobuf -%%% proto.message.IndexRowBinding %%% -``` - -```protobuf -%%% proto.message.FragmentBinding %%% -``` - -```protobuf -%%% proto.message.FragmentArray %%% -``` - -```protobuf -%%% proto.message.StableRowBinding %%% -``` - -```protobuf -%%% proto.message.RowIdSpans %%% -``` - -```protobuf -%%% proto.message.RowIdSpan %%% -``` - -## See also - -* [Index format](index.md) -* [Row addresses and stable row IDs](../table/row_id_lineage.md) -* [Fragment Reuse Index](system/frag_reuse.md) -* [Feature flags](../table/versioning.md#feature-flags) -* [Transaction V2](https://github.com/lance-format/lance/pull/7954) -* [Append and index in one commit](https://github.com/lance-format/lance/issues/10386) -* [Staged transactions](https://github.com/lance-format/lance/pull/10722) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index 21b006ae212..1dbcb8f2042 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -105,6 +105,8 @@ Index segments are created and updated through a transactional process: that carries no extra columns. Declaring a column here does not by itself make it servable -- see [Serving carried columns](#serving-carried-columns). - `fragment_bitmap`: The set of fragment IDs covered by this segment + - `fragment_id_map`: An optional mapping from stored local fragment IDs to committed + source fragment IDs (see [Fragment ID Mapping](#fragment-id-mapping)). - `index_details`: Index-specific configuration and parameters - `version`: The format version of this index type - See the full protobuf definition in [table.proto](https://github.com/lance-format/lance/blob/main/protos/table.proto). @@ -230,6 +232,8 @@ The `IndexMetadata` message contains important information about the index segme [Serving carried columns](#serving-carried-columns) and the legacy interpretation under [Covering-field contracts](#covering-field-contracts). - `fragment_bitmap`: the set of fragment IDs covered by this index segment. +- `fragment_id_map`: an optional mapping from stored local fragment IDs to committed + source fragment IDs (see [Fragment ID Mapping](#fragment-id-mapping)). - `index_details`: a protobuf `Any` message that contains index-specific details, such as index type, parameters, and storage format. This allows different index types to store their own metadata. @@ -246,6 +250,57 @@ There are both part of the `table.proto` file in the Lance source code. +### Fragment ID Mapping + +`IndexMetadata.fragment_id_map` (field 15) maps local fragment IDs in a segment's +physical row addresses to committed source fragment IDs, preserving row offsets. +This lets commit retries reuse prepared index files when a concurrent append +changes the allocation. When absent, the index keeps its normal committed row +references. + +For example, stored address `(17, 5)` with entry `17 -> 42` resolves to `(42, 5)`. +If another append takes fragment 42 first, a retry can publish `17 -> 43` without +rewriting the files. The manifest must publish the segment, map, and new source +fragments atomically using its fragment allocation. Each mapped value must point +to a committed fragment containing those indexed rows. + +```protobuf +%%% proto.message.FragmentIdMap %%% +``` + +A mapped segment must follow these rules: + +- **Complete physical mapping:** Map keys are scoped to the segment. The map must + be nonempty and cover every stored physical fragment ID, including unchanged + IDs as explicit `id -> id` entries. Keys and values must be less than `2^32 - 1`, + and distinct keys must have distinct values. Null and tombstone markers are + unchanged. Readers must reject invalid or unsupported maps. Only index types + and versions supporting physical addresses and this mapping may use it. + Logical row IDs and column values, including `_rowid` search keys, are unchanged. + +- **Resolution order:** Apply the map before the + [Fragment Reuse Index (FRI)](system/frag_reuse.md), then apply visibility, + deletion, and fragment ownership checks before ranking. With entry `17 -> 42` + and FRI translation `(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to + `(60, 3)`. Retargeting the map to fragment 60 would lose the offset change. + Cached translated addresses must be scoped to the effective map and FRI state. + +- **Coverage:** `fragment_bitmap` follows the applicable FRI coverage and + provenance rules. The map decodes immutable files and need not match current + coverage. Removing coverage must retain map entries needed to decode retained + files. + +- **Maintenance:** Operations that keep index files keep their map. Rewrites and + merges resolve each input segment's references exactly once. Output containing + committed IDs omits the map. Output containing local IDs carries a complete map + matching those files. Unsupported maintenance must fail before commit or + withdraw affected coverage so queries fall back to a scan. + +- **Feature flags:** Every manifest containing a mapped segment must set both + reader and writer [feature flags](../table/versioning.md#feature-flags). The bit + is unassigned. Writers must not emit field 15 until it is assigned and reader + and writer support, including maintenance, is available. + ### Index Segment Metadata Like `Manifest.table_metadata`, `IndexMetadata.metadata` is a `map` @@ -342,9 +397,3 @@ logical identifier that remains constant even when rows are moved during compact This feature is currently experimental. Performance evaluation is ongoing to determine when the tradeoff is worthwhile. - -## Durable row references - -Index files are immutable once written. Fragment IDs, and stable row IDs for new rows, are assigned when the commit builds the manifest. A concurrent commit can change those IDs after the index file has been written. - -[Durable index row references](durable_row_references.md) defines an optional `row_binding` on `IndexMetadata`. A retry replaces the binding and keeps the index files. Writers must not emit the field until its feature flag bit is assigned. diff --git a/protos/table.proto b/protos/table.proto index f941656ee81..a509420ff11 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -460,58 +460,20 @@ message IndexMetadata { */ map metadata = 13; - /* Resolves references stored in index files to committed IDs. - * Absent when the files already store committed IDs. - * Requires reader and writer feature flags. + /* Maps stored local fragment IDs to committed source fragment IDs, preserving row offsets. + * Absent when the index uses its normal committed row references. + * Requires both reader and writer feature flags once a feature bit is assigned. */ - optional IndexRowBinding row_binding = 14; + optional FragmentIdMap fragment_id_map = 15; } -/* A segment may bind fragment addresses, stable row IDs, or both. - * Readers reject an empty binding and an encoding they do not recognize. +/* Segment local mapping from stored fragment IDs to committed source fragment IDs. + * Must be nonempty and cover every physical fragment ID stored in the segment. + * Values must be unique committed fragment IDs, and keys and values must be less than 2^32 - 1. + * Applied before the Fragment Reuse Index (FRI). */ -message IndexRowBinding { - optional FragmentBinding fragments = 1; - optional StableRowBinding row_ids = 2; -} - -message FragmentBinding { - oneof encoding { - FragmentArray array = 1; - } -} - -/* Fragment ordinal i resolves to committed_fragment_ids[i]. - * The list is nonempty and its entries are unique. - * Entries remain in place when index coverage shrinks. - */ -message FragmentArray { - repeated uint32 committed_fragment_ids = 1; -} - -message StableRowBinding { - oneof encoding { - RowIdSpans spans = 1; - } -} - -/* Every stored row ID covered by this binding matches exactly one span. - * An empty list is corrupt. - */ -message RowIdSpans { - repeated RowIdSpan spans = 1; -} - -/* Maps [stored_base, stored_base + count) to - * [committed_base, committed_base + count). - * count must be greater than zero. - * Spans must not overlap in the stored ID space or the committed ID space. - * A span must not overflow uint64. - */ -message RowIdSpan { - uint64 stored_base = 1; - uint64 committed_base = 2; - uint64 count = 3; +message FragmentIdMap { + map entries = 1; } // Metadata about a single file within an index segment. diff --git a/rust/lance-table/src/format/index.rs b/rust/lance-table/src/format/index.rs index 3db3dd12f71..79c57b4f07d 100644 --- a/rust/lance-table/src/format/index.rs +++ b/rust/lance-table/src/format/index.rs @@ -743,11 +743,10 @@ impl IndexMetadata { }) .transpose()?; - // The files may contain local ordinals or provisional row ids. Dropping - // the binding here would publish those numbers as committed identities. - if proto.row_binding.is_some() { + // Reject mapped segments until stored fragment IDs can be resolved. + if proto.fragment_id_map.is_some() { return Err(Error::not_supported( - "index segment has a row binding, which this build does not apply", + "index segment has a fragment ID map, which this build does not support yet", )); } @@ -824,7 +823,7 @@ impl From<&IndexMetadata> for pb::IndexMetadata { created_at: idx.created_at.map(|dt| dt.timestamp_millis() as u64), base_id: idx.base_id, files, - row_binding: None, + fragment_id_map: None, } } } @@ -906,6 +905,7 @@ pub async fn list_index_files_with_sizes( #[cfg(test)] mod tests { use super::*; + use prost::Message; use rstest::rstest; use std::collections::HashMap; @@ -983,20 +983,47 @@ mod tests { } #[test] - fn test_index_metadata_rejects_a_row_binding() { + fn test_index_metadata_without_fragment_id_map() { + let metadata = index_metadata_with(vec![0], vec![]); + let proto = pb::IndexMetadata::from(&metadata); + assert!(proto.fragment_id_map.is_none()); + + let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); + assert!(decoded.fragment_id_map.is_none()); + assert_eq!(IndexMetadata::try_from(decoded).unwrap(), metadata); + } + + #[rstest] + #[case::mapped(vec![(17, 42), (29, 47)])] + #[case::empty(vec![])] + #[case::reserved_key(vec![(u32::MAX, 42)])] + #[case::reserved_source(vec![(17, u32::MAX)])] + #[case::aliased_sources(vec![(17, 42), (29, 42)])] + fn test_index_metadata_rejects_fragment_id_map(#[case] entries: Vec<(u32, u32)>) { let mut proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); - proto.row_binding = Some(pb::IndexRowBinding { - fragments: Some(pb::FragmentBinding { - encoding: Some(pb::fragment_binding::Encoding::Array(pb::FragmentArray { - committed_fragment_ids: vec![42, 47], - })), - }), - row_ids: None, + proto.fragment_id_map = Some(pb::FragmentIdMap { + entries: entries.into_iter().collect(), }); + let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); + assert_eq!(decoded.fragment_id_map, proto.fragment_id_map); - let err = IndexMetadata::try_from(proto).unwrap_err(); + let err = IndexMetadata::try_from(decoded).unwrap_err(); + assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); + assert!(err.to_string().contains("fragment ID map"), "got: {err}"); + } + + #[test] + fn test_index_metadata_rejects_unknown_fragment_id_map_content() { + let proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); + let mut bytes = proto.encode_to_vec(); + // Field 15 contains only an unknown field in FragmentIdMap. + bytes.extend_from_slice(&[0x7a, 0x02, 0x10, 0x01]); + let decoded = pb::IndexMetadata::decode(bytes.as_slice()).unwrap(); + assert_eq!(decoded.fragment_id_map, Some(pb::FragmentIdMap::default())); + + let err = IndexMetadata::try_from(decoded).unwrap_err(); assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); - assert!(err.to_string().contains("row binding"), "got: {err}"); + assert!(err.to_string().contains("fragment ID map"), "got: {err}"); } #[test] diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index ef1a310ac1c..137520d90b9 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1261,11 +1261,11 @@ pub struct IndexMetadata { #[prost(map = "string, string", tag = "13")] pub metadata: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - /// Resolves references stored in index files to committed IDs. - /// Absent when the files already store committed IDs. - /// Requires reader and writer feature flags. - #[prost(message, optional, tag = "14")] - pub row_binding: ::core::option::Option, + /// Maps stored local fragment IDs to committed source fragment IDs, preserving row offsets. + /// Absent when the index uses its normal committed row references. + /// Requires both reader and writer feature flags once a feature bit is assigned. + #[prost(message, optional, tag = "15")] + pub fragment_id_map: ::core::option::Option, } impl ::prost::Name for IndexMetadata { const NAME: &'static str = "IndexMetadata"; @@ -1277,128 +1277,23 @@ impl ::prost::Name for IndexMetadata { "/lance.table.IndexMetadata".into() } } -/// A segment may bind fragment addresses, stable row IDs, or both. -/// Readers reject an empty binding and an encoding they do not recognize. +/// Segment local mapping from stored fragment IDs to committed source fragment IDs. +/// Must be nonempty and cover every physical fragment ID stored in the segment. +/// Values must be unique committed fragment IDs, and keys and values must be less than 2^32 - 1. +/// Applied before the Fragment Reuse Index (FRI). #[derive(Clone, PartialEq, ::prost::Message)] -pub struct IndexRowBinding { - #[prost(message, optional, tag = "1")] - pub fragments: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub row_ids: ::core::option::Option, -} -impl ::prost::Name for IndexRowBinding { - const NAME: &'static str = "IndexRowBinding"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.IndexRowBinding".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.IndexRowBinding".into() - } -} -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct FragmentBinding { - #[prost(oneof = "fragment_binding::Encoding", tags = "1")] - pub encoding: ::core::option::Option, -} -/// Nested message and enum types in `FragmentBinding`. -pub mod fragment_binding { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Encoding { - #[prost(message, tag = "1")] - Array(super::FragmentArray), - } -} -impl ::prost::Name for FragmentBinding { - const NAME: &'static str = "FragmentBinding"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.FragmentBinding".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.FragmentBinding".into() - } -} -/// Fragment ordinal i resolves to committed_fragment_ids\[i\]. -/// The list is nonempty and its entries are unique. -/// Entries remain in place when index coverage shrinks. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct FragmentArray { - #[prost(uint32, repeated, tag = "1")] - pub committed_fragment_ids: ::prost::alloc::vec::Vec, -} -impl ::prost::Name for FragmentArray { - const NAME: &'static str = "FragmentArray"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.FragmentArray".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.FragmentArray".into() - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StableRowBinding { - #[prost(oneof = "stable_row_binding::Encoding", tags = "1")] - pub encoding: ::core::option::Option, -} -/// Nested message and enum types in `StableRowBinding`. -pub mod stable_row_binding { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Encoding { - #[prost(message, tag = "1")] - Spans(super::RowIdSpans), - } -} -impl ::prost::Name for StableRowBinding { - const NAME: &'static str = "StableRowBinding"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.StableRowBinding".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.StableRowBinding".into() - } -} -/// Every stored row ID covered by this binding matches exactly one span. -/// An empty list is corrupt. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RowIdSpans { - #[prost(message, repeated, tag = "1")] - pub spans: ::prost::alloc::vec::Vec, -} -impl ::prost::Name for RowIdSpans { - const NAME: &'static str = "RowIdSpans"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.RowIdSpans".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.RowIdSpans".into() - } -} -/// Maps [stored_base, stored_base + count) to -/// [committed_base, committed_base + count). -/// count must be greater than zero. -/// Spans must not overlap in the stored ID space or the committed ID space. -/// A span must not overflow uint64. -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct RowIdSpan { - #[prost(uint64, tag = "1")] - pub stored_base: u64, - #[prost(uint64, tag = "2")] - pub committed_base: u64, - #[prost(uint64, tag = "3")] - pub count: u64, +pub struct FragmentIdMap { + #[prost(map = "uint32, uint32", tag = "1")] + pub entries: ::std::collections::HashMap, } -impl ::prost::Name for RowIdSpan { - const NAME: &'static str = "RowIdSpan"; +impl ::prost::Name for FragmentIdMap { + const NAME: &'static str = "FragmentIdMap"; const PACKAGE: &'static str = "lance.table"; fn full_name() -> ::prost::alloc::string::String { - "lance.table.RowIdSpan".into() + "lance.table.FragmentIdMap".into() } fn type_url() -> ::prost::alloc::string::String { - "/lance.table.RowIdSpan".into() + "/lance.table.FragmentIdMap".into() } } /// Metadata about a single file within an index segment. From 10f719d2a637e68a66f79c0b9bb2900c0fc76ec1 Mon Sep 17 00:00:00 2001 From: geruh Date: Tue, 10 Nov 2026 17:34:07 -0800 Subject: [PATCH 3/7] address feedback --- docs/src/format/index/index.md | 88 ++++++++++---------------- docs/src/format/table/versioning.md | 3 +- protos/table.proto | 21 +++--- rust/lance-table/src/feature_flags.rs | 17 ++++- rust/lance-table/src/format/index.rs | 41 +++--------- rust/lance-table/src/pb/lance.table.rs | 33 +++------- rust/lance-tools/src/manifest.rs | 10 +-- 7 files changed, 84 insertions(+), 129 deletions(-) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index 1dbcb8f2042..faefe459930 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -105,8 +105,8 @@ Index segments are created and updated through a transactional process: that carries no extra columns. Declaring a column here does not by itself make it servable -- see [Serving carried columns](#serving-carried-columns). - `fragment_bitmap`: The set of fragment IDs covered by this segment - - `fragment_id_map`: An optional mapping from stored local fragment IDs to committed - source fragment IDs (see [Fragment ID Mapping](#fragment-id-mapping)). + - `fragment_id_map`: local fragment aliases. An empty map means no mapping + (see [Local fragment aliases](#local-fragment-aliases)). - `index_details`: Index-specific configuration and parameters - `version`: The format version of this index type - See the full protobuf definition in [table.proto](https://github.com/lance-format/lance/blob/main/protos/table.proto). @@ -232,8 +232,8 @@ The `IndexMetadata` message contains important information about the index segme [Serving carried columns](#serving-carried-columns) and the legacy interpretation under [Covering-field contracts](#covering-field-contracts). - `fragment_bitmap`: the set of fragment IDs covered by this index segment. -- `fragment_id_map`: an optional mapping from stored local fragment IDs to committed - source fragment IDs (see [Fragment ID Mapping](#fragment-id-mapping)). +- `fragment_id_map`: local fragment aliases. An empty map means no mapping + (see [Local fragment aliases](#local-fragment-aliases)). - `index_details`: a protobuf `Any` message that contains index-specific details, such as index type, parameters, and storage format. This allows different index types to store their own metadata. @@ -250,56 +250,36 @@ There are both part of the `table.proto` file in the Lance source code. -### Fragment ID Mapping - -`IndexMetadata.fragment_id_map` (field 15) maps local fragment IDs in a segment's -physical row addresses to committed source fragment IDs, preserving row offsets. -This lets commit retries reuse prepared index files when a concurrent append -changes the allocation. When absent, the index keeps its normal committed row -references. - -For example, stored address `(17, 5)` with entry `17 -> 42` resolves to `(42, 5)`. -If another append takes fragment 42 first, a retry can publish `17 -> 43` without -rewriting the files. The manifest must publish the segment, map, and new source -fragments atomically using its fragment allocation. Each mapped value must point -to a committed fragment containing those indexed rows. - -```protobuf -%%% proto.message.FragmentIdMap %%% -``` - -A mapped segment must follow these rules: - -- **Complete physical mapping:** Map keys are scoped to the segment. The map must - be nonempty and cover every stored physical fragment ID, including unchanged - IDs as explicit `id -> id` entries. Keys and values must be less than `2^32 - 1`, - and distinct keys must have distinct values. Null and tombstone markers are - unchanged. Readers must reject invalid or unsupported maps. Only index types - and versions supporting physical addresses and this mapping may use it. - Logical row IDs and column values, including `_rowid` search keys, are unchanged. - -- **Resolution order:** Apply the map before the - [Fragment Reuse Index (FRI)](system/frag_reuse.md), then apply visibility, - deletion, and fragment ownership checks before ranking. With entry `17 -> 42` - and FRI translation `(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to - `(60, 3)`. Retargeting the map to fragment 60 would lose the offset change. - Cached translated addresses must be scoped to the effective map and FRI state. - -- **Coverage:** `fragment_bitmap` follows the applicable FRI coverage and - provenance rules. The map decodes immutable files and need not match current - coverage. Removing coverage must retain map entries needed to decode retained - files. - -- **Maintenance:** Operations that keep index files keep their map. Rewrites and - merges resolve each input segment's references exactly once. Output containing - committed IDs omits the map. Output containing local IDs carries a complete map - matching those files. Unsupported maintenance must fail before commit or - withdraw affected coverage so queries fall back to a scan. - -- **Feature flags:** Every manifest containing a mapped segment must set both - reader and writer [feature flags](../table/versioning.md#feature-flags). The bit - is unassigned. Writers must not emit field 15 until it is assigned and reader - and writer support, including maintenance, is available. +### Local fragment aliases + +`IndexMetadata.fragment_id_map` (field 15) renames fragment IDs inside a +segment's physical row addresses so commit retries can reuse prepared index +files when fragment allocation changes. An empty map means no mapping. The map +is sparse: an entry `{17: 42}` maps fragment 17 to 42, while any unmapped +fragment ID (such as 29) keeps its original ID. Each stored fragment ID is +looked up once and never transitively. + +Apply `fragment_id_map` to valid physical row addresses before any other +address transformation, including [Fragment Reuse Index (FRI)](system/frag_reuse.md) +remap and deletion filtering, while preserving the 32-bit row offset. Logical +row IDs and column values are unchanged. For example, with entry `17 -> 42` and +FRI translation `(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to +`(60, 3)`. Retargeting the map directly to fragment 60 would lose the row +offset change. + +The index segment, its aliases, and any newly assigned fragments must be +committed together in one manifest, with each alias pointing to the fragment +that holds those indexed rows. Operations that retain an index file must retain +the aliases needed to decode it, while index rewrites and merges resolve each +input segment's aliases once. Keys and values must be less than `2^32 - 1`, and +two stored fragment IDs in the same segment must not resolve to the same final +fragment ID (for example, `{17: 42}` is invalid if the segment also stores 42 +and leaves 42 unmapped). + +A nonempty map requires `FLAG_LOCAL_FRAGMENT_ALIASES` (`2^20`) in both reader +and writer [feature flags](../table/versioning.md#feature-flags). The bit is +currently reserved and rejected by both readers and writers until runtime and +maintenance support lands. ### Index Segment Metadata diff --git a/docs/src/format/table/versioning.md b/docs/src/format/table/versioning.md index a50a18694ec..6d930dbcf53 100644 --- a/docs/src/format/table/versioning.md +++ b/docs/src/format/table/versioning.md @@ -43,9 +43,10 @@ they should return an "unsupported" error on any read or write operation. | `2^17` | `FLAG_OBJECT_METADATA` | No | Yes | The snapshot contains [clustering definitions, references, or a nonzero allocation high-water mark](clustering.md), nonempty [fragment metadata](index.md#fragment-metadata), or nonempty [index segment metadata](../index/index.md#index-segment-metadata). Reserved, unsupported until writers implement the maintenance rules. Readers may ignore this metadata. | | `2^18` | `FLAG_ROW_ADDR_INDICES` | No | Yes | A stable-row-ID table contains an index that stores physical row addresses. Older writers could treat its entries as stable row IDs and silently extend coverage without indexing rewritten fragments. | | `2^19` | `FLAG_INLINE_DELETIONS` | Yes | Yes | Some fragment stores its deletion vector in the manifest (`DeletionFile.inline`) rather than in a file under `_deletions/`. A reader without this flag would look for a file that does not exist. | +| `2^20` | `FLAG_LOCAL_FRAGMENT_ALIASES` | Yes | Yes | An index segment may set `IndexMetadata.fragment_id_map` to rename stored fragment IDs in physical row addresses. An empty map means no mapping. Reserved and unsupported until readers and index maintenance support aliases. See [Local fragment aliases](../index/index.md#local-fragment-aliases). | -Bits 16 and 17 are reserved but remain unsupported. Bits at positions 20 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, and zone write-seed reader and writer bits must each either both be set or both be clear; a half-set manifest is invalid. +Bits 16, 17, and 20 are reserved but remain unsupported. Bits at positions 21 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, and zone write-seed reader and writer bits must each either both be set or both be clear; a half-set manifest is invalid. Committing schema metadata `lance.blob.managed = "true"` activates the Managed Blob capability, even without new blob files. Ordinary Blob v2 writes without this opt-in do not activate it. Once activated, removing the opt-in, removing Blob fields, or restoring an older snapshot does not clear it. Before activation, all maintenance clients must support Managed Blobs: the flag cannot revoke old handles or prevent older clients from running cleanup through an unflagged historical snapshot. See [client compatibility](../../guide/blob.md#managed-objects-and-client-compatibility). diff --git a/protos/table.proto b/protos/table.proto index a509420ff11..37f939c68b9 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -460,20 +460,15 @@ message IndexMetadata { */ map metadata = 13; - /* Maps stored local fragment IDs to committed source fragment IDs, preserving row offsets. - * Absent when the index uses its normal committed row references. - * Requires both reader and writer feature flags once a feature bit is assigned. + /* Local fragment aliases for physical row addresses in this segment. + * An empty map means no mapping. Unmapped fragment IDs keep their value, and + * mapped IDs are looked up once before FRI remap or deletion filtering. + * + * Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and + * writer feature flags. Reserved until reader and index maintenance support + * lands. */ - optional FragmentIdMap fragment_id_map = 15; -} - -/* Segment local mapping from stored fragment IDs to committed source fragment IDs. - * Must be nonempty and cover every physical fragment ID stored in the segment. - * Values must be unique committed fragment IDs, and keys and values must be less than 2^32 - 1. - * Applied before the Fragment Reuse Index (FRI). - */ -message FragmentIdMap { - map entries = 1; + map fragment_id_map = 15; } // Metadata about a single file within an index segment. diff --git a/rust/lance-table/src/feature_flags.rs b/rust/lance-table/src/feature_flags.rs index fd291ba2430..852494aebcf 100644 --- a/rust/lance-table/src/feature_flags.rs +++ b/rust/lance-table/src/feature_flags.rs @@ -136,8 +136,12 @@ pub const FLAG_ROW_ADDR_INDICES: u64 = 1 << 18; /// (`DeletionFile.inline`) rather than in a file under `_deletions/`. A reader /// without this flag would look for a file that does not exist. pub const FLAG_INLINE_DELETIONS: u64 = 1 << 19; +/// Reserved for local fragment aliases (`IndexMetadata.fragment_id_map`). +/// Readers and writers reject it until readers and index maintenance support aliases. +/// This takes the next free bit. +pub const FLAG_LOCAL_FRAGMENT_ALIASES: u64 = 1 << 20; /// The first bit that is unknown as a feature flag -pub const FLAG_UNKNOWN: u64 = 1 << 20; +pub const FLAG_UNKNOWN: u64 = 1 << 21; const _: () = assert!(FLAG_COVERED_INDEX_METADATA < FLAG_UNKNOWN); // The fence needs a bit the current released build already refuses, which means @@ -158,6 +162,7 @@ const _: () = assert!(FLAG_ZONE_WRITE_SEEDS < FLAG_UNKNOWN); const _: () = assert!(FLAG_OBJECT_METADATA < FLAG_UNKNOWN); const _: () = assert!(FLAG_ROW_ADDR_INDICES < FLAG_UNKNOWN); const _: () = assert!(FLAG_INLINE_DELETIONS < FLAG_UNKNOWN); +const _: () = assert!(FLAG_LOCAL_FRAGMENT_ALIASES < FLAG_UNKNOWN); pub(crate) const STICKY_PAIRED_FLAGS: u64 = FLAG_MIXED_DATA_FILE_VERSIONS | FLAG_FRAGMENT_REUSE_INDEX @@ -566,6 +571,7 @@ fn supported_flags_when( ); // Reserved, not implemented: see the flag's doc comment. mark_supported(&mut supported, FLAG_FRAGMENT_TREE, false); + mark_supported(&mut supported, FLAG_LOCAL_FRAGMENT_ALIASES, false); mark_supported(&mut supported, FLAG_ZONE_WRITE_SEEDS, true); mark_supported(&mut supported, FLAG_OBJECT_METADATA, true); supported @@ -867,7 +873,7 @@ mod tests { assert_eq!(FLAG_INLINE_DELETIONS, 1 << 19); assert!(can_read_dataset(FLAG_INLINE_DELETIONS)); assert!(can_write_dataset(FLAG_INLINE_DELETIONS)); - assert_eq!(FLAG_UNKNOWN, 1 << 20); + assert_eq!(FLAG_UNKNOWN, 1 << 21); assert!(!can_read_dataset(FLAG_UNKNOWN)); assert!(!can_write_dataset(FLAG_UNKNOWN)); @@ -965,6 +971,13 @@ mod tests { } } + #[test] + fn test_local_fragment_aliases_flag_is_reserved() { + assert_eq!(FLAG_LOCAL_FRAGMENT_ALIASES, 1 << 20); + assert!(!can_read_dataset(FLAG_LOCAL_FRAGMENT_ALIASES)); + assert!(!can_write_dataset(FLAG_LOCAL_FRAGMENT_ALIASES)); + } + #[test] fn test_fragment_tree_flag_is_reserved_not_supported() { assert_eq!(FLAG_FRAGMENT_TREE, 4096); diff --git a/rust/lance-table/src/format/index.rs b/rust/lance-table/src/format/index.rs index 79c57b4f07d..9e0e3951871 100644 --- a/rust/lance-table/src/format/index.rs +++ b/rust/lance-table/src/format/index.rs @@ -743,8 +743,8 @@ impl IndexMetadata { }) .transpose()?; - // Reject mapped segments until stored fragment IDs can be resolved. - if proto.fragment_id_map.is_some() { + // An empty map means the segment uses its stored fragment IDs. + if !proto.fragment_id_map.is_empty() { return Err(Error::not_supported( "index segment has a fragment ID map, which this build does not support yet", )); @@ -823,7 +823,7 @@ impl From<&IndexMetadata> for pb::IndexMetadata { created_at: idx.created_at.map(|dt| dt.timestamp_millis() as u64), base_id: idx.base_id, files, - fragment_id_map: None, + fragment_id_map: Default::default(), } } } @@ -983,43 +983,22 @@ mod tests { } #[test] - fn test_index_metadata_without_fragment_id_map() { + fn test_index_metadata_empty_fragment_id_map_round_trips() { let metadata = index_metadata_with(vec![0], vec![]); let proto = pb::IndexMetadata::from(&metadata); - assert!(proto.fragment_id_map.is_none()); + assert!(proto.fragment_id_map.is_empty()); let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); - assert!(decoded.fragment_id_map.is_none()); + assert!(decoded.fragment_id_map.is_empty()); assert_eq!(IndexMetadata::try_from(decoded).unwrap(), metadata); } - #[rstest] - #[case::mapped(vec![(17, 42), (29, 47)])] - #[case::empty(vec![])] - #[case::reserved_key(vec![(u32::MAX, 42)])] - #[case::reserved_source(vec![(17, u32::MAX)])] - #[case::aliased_sources(vec![(17, 42), (29, 42)])] - fn test_index_metadata_rejects_fragment_id_map(#[case] entries: Vec<(u32, u32)>) { + #[test] + fn test_index_metadata_rejects_fragment_id_map() { let mut proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); - proto.fragment_id_map = Some(pb::FragmentIdMap { - entries: entries.into_iter().collect(), - }); + proto.fragment_id_map.insert(17, 42); let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); - assert_eq!(decoded.fragment_id_map, proto.fragment_id_map); - - let err = IndexMetadata::try_from(decoded).unwrap_err(); - assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); - assert!(err.to_string().contains("fragment ID map"), "got: {err}"); - } - - #[test] - fn test_index_metadata_rejects_unknown_fragment_id_map_content() { - let proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); - let mut bytes = proto.encode_to_vec(); - // Field 15 contains only an unknown field in FragmentIdMap. - bytes.extend_from_slice(&[0x7a, 0x02, 0x10, 0x01]); - let decoded = pb::IndexMetadata::decode(bytes.as_slice()).unwrap(); - assert_eq!(decoded.fragment_id_map, Some(pb::FragmentIdMap::default())); + assert_eq!(decoded.fragment_id_map.get(&17), Some(&42)); let err = IndexMetadata::try_from(decoded).unwrap_err(); assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index 137520d90b9..7ba4d263f26 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1261,11 +1261,15 @@ pub struct IndexMetadata { #[prost(map = "string, string", tag = "13")] pub metadata: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - /// Maps stored local fragment IDs to committed source fragment IDs, preserving row offsets. - /// Absent when the index uses its normal committed row references. - /// Requires both reader and writer feature flags once a feature bit is assigned. - #[prost(message, optional, tag = "15")] - pub fragment_id_map: ::core::option::Option, + /// Local fragment aliases for physical row addresses in this segment. + /// An empty map means no mapping. Unmapped fragment IDs keep their value, and + /// mapped IDs are looked up once before FRI remap or deletion filtering. + /// + /// Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and + /// writer feature flags. Reserved until reader and index maintenance support + /// lands. + #[prost(map = "uint32, uint32", tag = "15")] + pub fragment_id_map: ::std::collections::HashMap, } impl ::prost::Name for IndexMetadata { const NAME: &'static str = "IndexMetadata"; @@ -1277,25 +1281,6 @@ impl ::prost::Name for IndexMetadata { "/lance.table.IndexMetadata".into() } } -/// Segment local mapping from stored fragment IDs to committed source fragment IDs. -/// Must be nonempty and cover every physical fragment ID stored in the segment. -/// Values must be unique committed fragment IDs, and keys and values must be less than 2^32 - 1. -/// Applied before the Fragment Reuse Index (FRI). -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FragmentIdMap { - #[prost(map = "uint32, uint32", tag = "1")] - pub entries: ::std::collections::HashMap, -} -impl ::prost::Name for FragmentIdMap { - const NAME: &'static str = "FragmentIdMap"; - const PACKAGE: &'static str = "lance.table"; - fn full_name() -> ::prost::alloc::string::String { - "lance.table.FragmentIdMap".into() - } - fn type_url() -> ::prost::alloc::string::String { - "/lance.table.FragmentIdMap".into() - } -} /// Metadata about a single file within an index segment. #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] pub struct IndexFile { diff --git a/rust/lance-tools/src/manifest.rs b/rust/lance-tools/src/manifest.rs index 70ef99b8e5f..ed20eb21bf2 100644 --- a/rust/lance-tools/src/manifest.rs +++ b/rust/lance-tools/src/manifest.rs @@ -10,10 +10,10 @@ use lance_table::feature_flags::{ FLAG_BASE_PATHS, FLAG_COVERED_INDEX_METADATA, FLAG_DELETION_FILES, FLAG_DISABLE_TRANSACTION_FILE, FLAG_FRAG_REUSE_WITH_STABLE_ROW_IDS, FLAG_FRAGMENT_REUSE_INDEX, FLAG_FRAGMENT_TREE, FLAG_INDEPENDENT_COVERING_FIELDS, FLAG_INLINE_DELETIONS, - FLAG_MANAGED_BLOBS, FLAG_MIXED_DATA_FILE_VERSIONS, FLAG_NON_REUSABLE_FIELD_IDS, - FLAG_OBJECT_METADATA, FLAG_ROW_ADDR_INDICES, FLAG_SPILLED_ROW_LINEAGE, FLAG_STABLE_ROW_IDS, - FLAG_TABLE_CONFIG, FLAG_UNKNOWN, FLAG_UNSTABLE_DATA_OVERLAY_FILES, - FLAG_USE_V2_FORMAT_DEPRECATED, FLAG_ZONE_WRITE_SEEDS, + FLAG_LOCAL_FRAGMENT_ALIASES, FLAG_MANAGED_BLOBS, FLAG_MIXED_DATA_FILE_VERSIONS, + FLAG_NON_REUSABLE_FIELD_IDS, FLAG_OBJECT_METADATA, FLAG_ROW_ADDR_INDICES, + FLAG_SPILLED_ROW_LINEAGE, FLAG_STABLE_ROW_IDS, FLAG_TABLE_CONFIG, FLAG_UNKNOWN, + FLAG_UNSTABLE_DATA_OVERLAY_FILES, FLAG_USE_V2_FORMAT_DEPRECATED, FLAG_ZONE_WRITE_SEEDS, }; use lance_table::format::overlay::OverlayCoverage; use lance_table::format::{ @@ -1347,6 +1347,7 @@ fn format_feature_flags(flags: u64) -> String { (FLAG_OBJECT_METADATA, "object_metadata"), (FLAG_ROW_ADDR_INDICES, "row_addr_indices"), (FLAG_INLINE_DELETIONS, "inline_deletions"), + (FLAG_LOCAL_FRAGMENT_ALIASES, "local_fragment_aliases"), ]; let mut names = known_flags .iter() @@ -1623,6 +1624,7 @@ mod tests { (FLAG_OBJECT_METADATA, "object_metadata"), (FLAG_ROW_ADDR_INDICES, "row_addr_indices"), (FLAG_INLINE_DELETIONS, "inline_deletions"), + (FLAG_LOCAL_FRAGMENT_ALIASES, "local_fragment_aliases"), ]; let rendered = format_feature_flags(FLAG_UNKNOWN - 1); for (_, name) in known_flags { From e63c48f27df2f949d173af806f9ebe7dbae5d3fd Mon Sep 17 00:00:00 2001 From: geruh Date: Wed, 11 Nov 2026 17:25:59 -0800 Subject: [PATCH 4/7] clean up docs and address feedback --- docs/src/format/index/index.md | 73 +++++++++++++++----------- docs/src/format/table/versioning.md | 8 +-- protos/table.proto | 26 ++++++--- rust/lance-table/src/feature_flags.rs | 59 +++++++++++++++++++-- rust/lance-table/src/format/index.rs | 23 ++++---- rust/lance-table/src/pb/lance.table.rs | 28 +++++++--- 6 files changed, 155 insertions(+), 62 deletions(-) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index faefe459930..55d62a2b2ca 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -54,7 +54,7 @@ Each segment is an independent, self-contained index covering a subset of the da Each index segment covers a disjoint subset of fragments in the dataset. The segments must cover all rows in the fragments they cover, with one exception: if a fragment has delete markers at the time of index creation, the index segment is allowed to not contain the deleted rows. The fragments an index -covers are those recorded in the `fragment_bitmap` field. +covers are the committed fragment IDs recorded in the `fragment_bitmap` field. Index segments together **do not** need to cover all fragments. This means an index isn't required to be fully up-to-date. When this happens, engines can split their queries into indexed and unindexed @@ -104,8 +104,9 @@ Index segments are created and updated through a transactional process: may appear in both lists when the index carries a value it is also keyed on. Empty for an index that carries no extra columns. Declaring a column here does not by itself make it servable -- see [Serving carried columns](#serving-carried-columns). - - `fragment_bitmap`: The set of fragment IDs covered by this segment - - `fragment_id_map`: local fragment aliases. An empty map means no mapping + - `fragment_bitmap`: The committed fragment IDs covered by this segment + - `local_fragment_aliases`: fragment IDs referenced by the segment's files, mapped + to committed fragment IDs. An empty map means no mapping (see [Local fragment aliases](#local-fragment-aliases)). - `index_details`: Index-specific configuration and parameters - `version`: The format version of this index type @@ -231,8 +232,9 @@ The `IndexMetadata` message contains important information about the index segme authoritative for what the segment can serve -- see [Serving carried columns](#serving-carried-columns) and the legacy interpretation under [Covering-field contracts](#covering-field-contracts). -- `fragment_bitmap`: the set of fragment IDs covered by this index segment. -- `fragment_id_map`: local fragment aliases. An empty map means no mapping +- `fragment_bitmap`: the committed fragment IDs covered by this index segment. +- `local_fragment_aliases`: fragment IDs referenced by the segment's files, mapped + to committed fragment IDs. An empty map means no mapping (see [Local fragment aliases](#local-fragment-aliases)). - `index_details`: a protobuf `Any` message that contains index-specific details, such as index type, parameters, and storage format. This allows different index types to store their own metadata. @@ -252,34 +254,43 @@ There are both part of the `table.proto` file in the Lance source code. ### Local fragment aliases -`IndexMetadata.fragment_id_map` (field 15) renames fragment IDs inside a -segment's physical row addresses so commit retries can reuse prepared index -files when fragment allocation changes. An empty map means no mapping. The map -is sparse: an entry `{17: 42}` maps fragment 17 to 42, while any unmapped -fragment ID (such as 29) keeps its original ID. Each stored fragment ID is -looked up once and never transitively. - -Apply `fragment_id_map` to valid physical row addresses before any other -address transformation, including [Fragment Reuse Index (FRI)](system/frag_reuse.md) -remap and deletion filtering, while preserving the 32-bit row offset. Logical -row IDs and column values are unchanged. For example, with entry `17 -> 42` and -FRI translation `(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to -`(60, 3)`. Retargeting the map directly to fragment 60 would lose the row -offset change. - -The index segment, its aliases, and any newly assigned fragments must be -committed together in one manifest, with each alias pointing to the fragment -that holds those indexed rows. Operations that retain an index file must retain -the aliases needed to decode it, while index rewrites and merges resolve each -input segment's aliases once. Keys and values must be less than `2^32 - 1`, and -two stored fragment IDs in the same segment must not resolve to the same final -fragment ID (for example, `{17: 42}` is invalid if the segment also stores 42 -and leaves 42 unmapped). +`IndexMetadata.local_fragment_aliases` (field 14) translates fragment IDs +referenced by a segment's files so a commit retry can reuse prepared index +files when fragment allocation changes. An empty map means no mapping. An +entry `{17: 42}` maps fragment 17 to 42, and any unmapped fragment ID keeps +its original ID. Each stored fragment ID is looked up once. + +The map applies to fragment references in the segment's files, including +physical row addresses and references stored by BTree, ZoneMap, and BloomFilter. +Apply it once, before any later transformation, including +[Fragment Reuse Index (FRI)](system/frag_reuse.md) remap. A physical row +address keeps its 32-bit row offset. Stable logical row IDs and user column +values are unchanged. With entry `17 -> 42` and FRI translation +`(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to `(60, 3)`. +Retargeting the map directly to fragment 60 would lose the row offset change. + +`fragment_bitmap` stores committed source fragment IDs before FRI remapping, +while `local_fragment_aliases` translates fragment IDs referenced by the index +files. A commit or rebase updates the bitmap and aliases together without +rewriting the index files. For example, local fragment 17 committing as +dataset fragment 42 records `local_fragment_aliases: {17: 42}` and +`fragment_bitmap: {42}`. If conflict resolution rebases that fragment to 43, +the manifest updates to `local_fragment_aliases: {17: 43}` and +`fragment_bitmap: {43}`. + +Operations that retain index files must retain their aliases. Index rewrites +and merges must resolve aliases before writing replacement files. + +Keys and values must be less than `2^32 - 1`. `u32::MAX` (`2^32 - 1`) is +reserved for `RowAddress::TOMBSTONE_FRAG`. Two stored fragment IDs in the same +segment must not resolve to the same final fragment ID. `{17: 42}` is invalid +when the segment also stores 42 and leaves 42 unmapped. A nonempty map requires `FLAG_LOCAL_FRAGMENT_ALIASES` (`2^20`) in both reader -and writer [feature flags](../table/versioning.md#feature-flags). The bit is -currently reserved and rejected by both readers and writers until runtime and -maintenance support lands. +and writer [feature flags](../table/versioning.md#feature-flags). Both bits +are set while any retained segment has a nonempty map, including when +`fragment_bitmap` is empty, and cleared when none do. The flag is reserved. +Readers and writers reject it until alias support lands. ### Index Segment Metadata diff --git a/docs/src/format/table/versioning.md b/docs/src/format/table/versioning.md index 6d930dbcf53..cf5ac81073c 100644 --- a/docs/src/format/table/versioning.md +++ b/docs/src/format/table/versioning.md @@ -39,14 +39,14 @@ they should return an "unsupported" error on any read or write operation. | `2^13` | `FLAG_INDEPENDENT_COVERING_FIELDS` | Yes | Yes | Requires `FLAG_COVERED_INDEX_METADATA` and is retained together with it. `IndexMetadata.fields` contains only key fields, while `covering_fields` independently declares carried fields and may overlap `fields`. Implementations that only support the legacy suffix contract must reject the dataset. | | `2^14` | `FLAG_MANAGED_BLOBS` | Yes | Yes | Blob descriptors independently address owned objects. Readers resolve the descriptor's base and path; cleanup preserves objects referenced by protected snapshots, independently of the original data file. Both bits remain set on later versions, including restores. See [Blob v2 capability and compatibility](blob.md#capability-and-compatibility). | | `2^15` | `FLAG_NON_REUSABLE_FIELD_IDS` | No | Yes | The manifest sets `max_allocated_field_id`, and a writer must assign new field IDs above it. Before activation, all clients that can write to the dataset must enforce writer feature flags. See [Field IDs](schema.md#field-ids). | -| `2^16` | `FLAG_ZONE_WRITE_SEEDS` | Yes | Yes | Referenced data files contain version 1 [zone write seeds](../index/scalar/zone_write_seeds.md). Both bits remain set in derived snapshots, including clone and restore. Reserved and unsupported until implemented. | -| `2^17` | `FLAG_OBJECT_METADATA` | No | Yes | The snapshot contains [clustering definitions, references, or a nonzero allocation high-water mark](clustering.md), nonempty [fragment metadata](index.md#fragment-metadata), or nonempty [index segment metadata](../index/index.md#index-segment-metadata). Reserved, unsupported until writers implement the maintenance rules. Readers may ignore this metadata. | +| `2^16` | `FLAG_ZONE_WRITE_SEEDS` | Yes | Yes | Referenced data files contain version 1 [zone write seeds](../index/scalar/zone_write_seeds.md). Both bits remain set in derived snapshots, including clone and restore. | +| `2^17` | `FLAG_OBJECT_METADATA` | No | Yes | The snapshot contains [clustering definitions, references, or a nonzero allocation high-water mark](clustering.md), nonempty [fragment metadata](index.md#fragment-metadata), or nonempty [index segment metadata](../index/index.md#index-segment-metadata). Readers may ignore this metadata. | | `2^18` | `FLAG_ROW_ADDR_INDICES` | No | Yes | A stable-row-ID table contains an index that stores physical row addresses. Older writers could treat its entries as stable row IDs and silently extend coverage without indexing rewritten fragments. | | `2^19` | `FLAG_INLINE_DELETIONS` | Yes | Yes | Some fragment stores its deletion vector in the manifest (`DeletionFile.inline`) rather than in a file under `_deletions/`. A reader without this flag would look for a file that does not exist. | -| `2^20` | `FLAG_LOCAL_FRAGMENT_ALIASES` | Yes | Yes | An index segment may set `IndexMetadata.fragment_id_map` to rename stored fragment IDs in physical row addresses. An empty map means no mapping. Reserved and unsupported until readers and index maintenance support aliases. See [Local fragment aliases](../index/index.md#local-fragment-aliases). | +| `2^20` | `FLAG_LOCAL_FRAGMENT_ALIASES` | Yes | Yes | An index segment may set `IndexMetadata.local_fragment_aliases` to translate fragment IDs stored in its files. `fragment_bitmap` stores the committed fragment IDs. Both bits are set while any retained segment has a nonempty map, including when `fragment_bitmap` is empty, and both are cleared when none do. Unsupported until readers and index maintenance implement aliases. See [Local fragment aliases](../index/index.md#local-fragment-aliases). | -Bits 16, 17, and 20 are reserved but remain unsupported. Bits at positions 21 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, and zone write-seed reader and writer bits must each either both be set or both be clear; a half-set manifest is invalid. +Bits 12, 13, and 20 are reserved and remain unsupported. Bits 16 and 17 are supported. Bits at positions 21 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, zone write-seed, and local fragment alias reader and writer bits must each either both be set or both be clear. A half-set manifest is invalid. Committing schema metadata `lance.blob.managed = "true"` activates the Managed Blob capability, even without new blob files. Ordinary Blob v2 writes without this opt-in do not activate it. Once activated, removing the opt-in, removing Blob fields, or restoring an older snapshot does not clear it. Before activation, all maintenance clients must support Managed Blobs: the flag cannot revoke old handles or prevent older clients from running cleanup through an unflagged historical snapshot. See [client compatibility](../../guide/blob.md#managed-objects-and-client-compatibility). diff --git a/protos/table.proto b/protos/table.proto index 37f939c68b9..6902bd954e5 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -370,6 +370,11 @@ message IndexMetadata { uint64 dataset_version = 4; /* A bitmap of the included fragment ids. + * + * Stores committed dataset fragment IDs (before FRI remapping), not local + * fragment IDs stored inside index files. When `local_fragment_aliases` is + * used, a commit or rebase updates this bitmap and the aliases together + * without rewriting the index files. * * This may by used to determine how much of the dataset is covered by the * index. This information can be retrieved from the dataset by looking at @@ -460,15 +465,24 @@ message IndexMetadata { */ map metadata = 13; - /* Local fragment aliases for physical row addresses in this segment. - * An empty map means no mapping. Unmapped fragment IDs keep their value, and - * mapped IDs are looked up once before FRI remap or deletion filtering. + /* Sparse map from fragment IDs stored in this segment's files to committed + * fragment IDs. An empty map means no mapping. Unmapped IDs keep their + * value. Each stored ID is translated once. + * + * Applies to fragment references in the segment, including physical row + * addresses, BTree, ZoneMap, and BloomFilter. A row address keeps its row + * offset. Stable logical row IDs and user column values are not translated. + * + * Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is + * reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not + * resolve to the same final fragment ID. * * Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and - * writer feature flags. Reserved until reader and index maintenance support - * lands. + * writer feature flags while nonempty. Both bits are cleared when no + * retained segment has a nonempty map. Reserved until readers and index + * maintenance support aliases. */ - map fragment_id_map = 15; + map local_fragment_aliases = 14; } // Metadata about a single file within an index segment. diff --git a/rust/lance-table/src/feature_flags.rs b/rust/lance-table/src/feature_flags.rs index 852494aebcf..a4c398e8d23 100644 --- a/rust/lance-table/src/feature_flags.rs +++ b/rust/lance-table/src/feature_flags.rs @@ -136,9 +136,10 @@ pub const FLAG_ROW_ADDR_INDICES: u64 = 1 << 18; /// (`DeletionFile.inline`) rather than in a file under `_deletions/`. A reader /// without this flag would look for a file that does not exist. pub const FLAG_INLINE_DELETIONS: u64 = 1 << 19; -/// Reserved for local fragment aliases (`IndexMetadata.fragment_id_map`). -/// Readers and writers reject it until readers and index maintenance support aliases. -/// This takes the next free bit. +/// Reserved for local fragment aliases (`IndexMetadata.local_fragment_aliases`). +/// Both reader and writer bits are required while any retained index segment +/// has aliases. The flag is non-sticky and unsupported until reader and +/// index maintenance support lands. pub const FLAG_LOCAL_FRAGMENT_ALIASES: u64 = 1 << 20; /// The first bit that is unknown as a feature flag pub const FLAG_UNKNOWN: u64 = 1 << 21; @@ -665,6 +666,7 @@ pub fn validate_paired_feature_flags(manifest: &Manifest) -> Result<()> { (FLAG_MIXED_DATA_FILE_VERSIONS, "mixed data-file-version"), (FLAG_MANAGED_BLOBS, "Managed Blob"), (FLAG_ZONE_WRITE_SEEDS, "zone write seed"), + (FLAG_LOCAL_FRAGMENT_ALIASES, "local fragment aliases"), ] { let reader = manifest.reader_feature_flags & flag != 0; let writer = manifest.writer_feature_flags & flag != 0; @@ -972,10 +974,59 @@ mod tests { } #[test] - fn test_local_fragment_aliases_flag_is_reserved() { + fn test_local_fragment_aliases_are_paired_and_not_sticky() { assert_eq!(FLAG_LOCAL_FRAGMENT_ALIASES, 1 << 20); assert!(!can_read_dataset(FLAG_LOCAL_FRAGMENT_ALIASES)); assert!(!can_write_dataset(FLAG_LOCAL_FRAGMENT_ALIASES)); + assert_eq!(STICKY_PAIRED_FLAGS & FLAG_LOCAL_FRAGMENT_ALIASES, 0); + + for (reader, writer) in [ + (FLAG_LOCAL_FRAGMENT_ALIASES, 0), + (0, FLAG_LOCAL_FRAGMENT_ALIASES), + ] { + let mut manifest = empty_manifest(); + manifest.reader_feature_flags = reader; + manifest.writer_feature_flags = writer; + let error = validate_paired_feature_flags(&manifest).unwrap_err(); + assert!(matches!(error, Error::CorruptFile { .. }), "{error:?}"); + assert!( + error.to_string().contains("local fragment aliases"), + "{error}" + ); + } + + let mut manifest = empty_manifest(); + manifest.reader_feature_flags = FLAG_LOCAL_FRAGMENT_ALIASES; + manifest.writer_feature_flags = FLAG_LOCAL_FRAGMENT_ALIASES; + validate_paired_feature_flags(&manifest).unwrap(); + let error = ensure_can_read_manifest(&manifest).unwrap_err(); + assert!(matches!(error, Error::NotSupported { .. }), "{error:?}"); + let error = ensure_can_write_manifest(&manifest).unwrap_err(); + assert!(matches!(error, Error::NotSupported { .. }), "{error:?}"); + + apply_feature_flags(&mut manifest, false, false).unwrap(); + assert_eq!( + manifest.reader_feature_flags & FLAG_LOCAL_FRAGMENT_ALIASES, + 0 + ); + assert_eq!( + manifest.writer_feature_flags & FLAG_LOCAL_FRAGMENT_ALIASES, + 0 + ); + + let mut source = empty_manifest(); + source.reader_feature_flags = FLAG_LOCAL_FRAGMENT_ALIASES; + source.writer_feature_flags = FLAG_LOCAL_FRAGMENT_ALIASES; + let mut destination = empty_manifest(); + inherit_sticky_feature_flags(&mut destination, &source).unwrap(); + assert_eq!( + destination.reader_feature_flags & FLAG_LOCAL_FRAGMENT_ALIASES, + 0 + ); + assert_eq!( + destination.writer_feature_flags & FLAG_LOCAL_FRAGMENT_ALIASES, + 0 + ); } #[test] diff --git a/rust/lance-table/src/format/index.rs b/rust/lance-table/src/format/index.rs index 9e0e3951871..4aa88fcafec 100644 --- a/rust/lance-table/src/format/index.rs +++ b/rust/lance-table/src/format/index.rs @@ -744,9 +744,9 @@ impl IndexMetadata { .transpose()?; // An empty map means the segment uses its stored fragment IDs. - if !proto.fragment_id_map.is_empty() { + if !proto.local_fragment_aliases.is_empty() { return Err(Error::not_supported( - "index segment has a fragment ID map, which this build does not support yet", + "index segment has local fragment aliases, which this build does not support yet", )); } @@ -823,7 +823,7 @@ impl From<&IndexMetadata> for pb::IndexMetadata { created_at: idx.created_at.map(|dt| dt.timestamp_millis() as u64), base_id: idx.base_id, files, - fragment_id_map: Default::default(), + local_fragment_aliases: Default::default(), } } } @@ -983,26 +983,29 @@ mod tests { } #[test] - fn test_index_metadata_empty_fragment_id_map_round_trips() { + fn test_index_metadata_empty_local_fragment_aliases_round_trip() { let metadata = index_metadata_with(vec![0], vec![]); let proto = pb::IndexMetadata::from(&metadata); - assert!(proto.fragment_id_map.is_empty()); + assert!(proto.local_fragment_aliases.is_empty()); let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); - assert!(decoded.fragment_id_map.is_empty()); + assert!(decoded.local_fragment_aliases.is_empty()); assert_eq!(IndexMetadata::try_from(decoded).unwrap(), metadata); } #[test] - fn test_index_metadata_rejects_fragment_id_map() { + fn test_index_metadata_rejects_local_fragment_aliases() { let mut proto = pb::IndexMetadata::from(&index_metadata_with(vec![0], vec![])); - proto.fragment_id_map.insert(17, 42); + proto.local_fragment_aliases.insert(17, 42); let decoded = pb::IndexMetadata::decode(proto.encode_to_vec().as_slice()).unwrap(); - assert_eq!(decoded.fragment_id_map.get(&17), Some(&42)); + assert_eq!(decoded.local_fragment_aliases.get(&17), Some(&42)); let err = IndexMetadata::try_from(decoded).unwrap_err(); assert!(matches!(err, Error::NotSupported { .. }), "got: {err:?}"); - assert!(err.to_string().contains("fragment ID map"), "got: {err}"); + assert!( + err.to_string().contains("local fragment aliases"), + "got: {err}" + ); } #[test] diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index 7ba4d263f26..0ea1ee02caa 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1179,6 +1179,11 @@ pub struct IndexMetadata { pub dataset_version: u64, /// A bitmap of the included fragment ids. /// + /// Stores committed dataset fragment IDs (before FRI remapping), not local + /// fragment IDs stored inside index files. When `local_fragment_aliases` is + /// used, a commit or rebase updates this bitmap and the aliases together + /// without rewriting the index files. + /// /// This may by used to determine how much of the dataset is covered by the /// index. This information can be retrieved from the dataset by looking at /// the dataset at `dataset_version`. However, since the old version may be @@ -1261,15 +1266,24 @@ pub struct IndexMetadata { #[prost(map = "string, string", tag = "13")] pub metadata: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>, - /// Local fragment aliases for physical row addresses in this segment. - /// An empty map means no mapping. Unmapped fragment IDs keep their value, and - /// mapped IDs are looked up once before FRI remap or deletion filtering. + /// Sparse map from fragment IDs stored in this segment's files to committed + /// fragment IDs. An empty map means no mapping. Unmapped IDs keep their + /// value. Each stored ID is translated once. + /// + /// Applies to fragment references in the segment, including physical row + /// addresses, BTree, ZoneMap, and BloomFilter. A row address keeps its row + /// offset. Stable logical row IDs and user column values are not translated. + /// + /// Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is + /// reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not + /// resolve to the same final fragment ID. /// /// Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and - /// writer feature flags. Reserved until reader and index maintenance support - /// lands. - #[prost(map = "uint32, uint32", tag = "15")] - pub fragment_id_map: ::std::collections::HashMap, + /// writer feature flags while nonempty. Both bits are cleared when no + /// retained segment has a nonempty map. Reserved until readers and index + /// maintenance support aliases. + #[prost(map = "uint32, uint32", tag = "14")] + pub local_fragment_aliases: ::std::collections::HashMap, } impl ::prost::Name for IndexMetadata { const NAME: &'static str = "IndexMetadata"; From 320fe605d66689ce6ef6c4ca8e55a1686ba63fb8 Mon Sep 17 00:00:00 2001 From: geruh Date: Wed, 11 Nov 2026 17:51:47 -0800 Subject: [PATCH 5/7] remove mention of index types --- docs/src/format/index/index.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index 55d62a2b2ca..f2bc2365cfe 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -260,8 +260,7 @@ files when fragment allocation changes. An empty map means no mapping. An entry `{17: 42}` maps fragment 17 to 42, and any unmapped fragment ID keeps its original ID. Each stored fragment ID is looked up once. -The map applies to fragment references in the segment's files, including -physical row addresses and references stored by BTree, ZoneMap, and BloomFilter. +The map applies to fragment IDs referenced by the segment's files. Apply it once, before any later transformation, including [Fragment Reuse Index (FRI)](system/frag_reuse.md) remap. A physical row address keeps its 32-bit row offset. Stable logical row IDs and user column From f1e8ac8afd5e2d77497714d4b283cc307705ad86 Mon Sep 17 00:00:00 2001 From: geruh Date: Mon, 16 Nov 2026 11:00:39 -0800 Subject: [PATCH 6/7] cleanup wording --- docs/src/format/index/index.md | 23 ++++++++++++++--------- docs/src/format/table/versioning.md | 2 +- protos/table.proto | 7 ++++--- rust/lance-table/src/pb/lance.table.rs | 7 ++++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index f2bc2365cfe..859da8260cd 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -258,7 +258,8 @@ There are both part of the `table.proto` file in the Lance source code. referenced by a segment's files so a commit retry can reuse prepared index files when fragment allocation changes. An empty map means no mapping. An entry `{17: 42}` maps fragment 17 to 42, and any unmapped fragment ID keeps -its original ID. Each stored fragment ID is looked up once. +its original ID. Translation is not transitive: with `{17: 42, 42: 43}`, +stored 17 resolves to 42, not 43. The map applies to fragment IDs referenced by the segment's files. Apply it once, before any later transformation, including @@ -268,14 +269,18 @@ values are unchanged. With entry `17 -> 42` and FRI translation `(42, 5) -> (60, 3)`, stored address `(17, 5)` resolves to `(60, 3)`. Retargeting the map directly to fragment 60 would lose the row offset change. -`fragment_bitmap` stores committed source fragment IDs before FRI remapping, -while `local_fragment_aliases` translates fragment IDs referenced by the index -files. A commit or rebase updates the bitmap and aliases together without -rewriting the index files. For example, local fragment 17 committing as -dataset fragment 42 records `local_fragment_aliases: {17: 42}` and -`fragment_bitmap: {42}`. If conflict resolution rebases that fragment to 43, -the manifest updates to `local_fragment_aliases: {17: 43}` and -`fragment_bitmap: {43}`. +A segment whose files store stable row IDs must not carry local fragment +aliases. A commit retry can reassign row IDs as well as fragment IDs, and the +map cannot translate row IDs. + +`fragment_bitmap` must hold committed fragment IDs, before FRI remapping. +When a commit or rebase changes the committed ID of a fragment referenced +through `local_fragment_aliases`, it must update `fragment_bitmap` and the +aliases together. The index files do not need to be rewritten. For example, +local fragment 17 committing as dataset fragment 42 records +`local_fragment_aliases: {17: 42}` and `fragment_bitmap: {42}`. If conflict +resolution rebases that fragment to 43, the manifest updates to +`local_fragment_aliases: {17: 43}` and `fragment_bitmap: {43}`. Operations that retain index files must retain their aliases. Index rewrites and merges must resolve aliases before writing replacement files. diff --git a/docs/src/format/table/versioning.md b/docs/src/format/table/versioning.md index cf5ac81073c..f64b8359455 100644 --- a/docs/src/format/table/versioning.md +++ b/docs/src/format/table/versioning.md @@ -47,6 +47,6 @@ they should return an "unsupported" error on any read or write operation. -Bits 12, 13, and 20 are reserved and remain unsupported. Bits 16 and 17 are supported. Bits at positions 21 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, zone write-seed, and local fragment alias reader and writer bits must each either both be set or both be clear. A half-set manifest is invalid. +Bits 12 and 20 are reserved and remain unsupported. Bits 13, 16, and 17 are supported. Bits at positions 21 and above are unknown. Unknown or unsupported flags cause implementations to reject the corresponding read or write operation with an "unsupported" error. The paired mixed-version, Managed Blob, zone write-seed, and local fragment alias reader and writer bits must each either both be set or both be clear. A half-set manifest is invalid. Committing schema metadata `lance.blob.managed = "true"` activates the Managed Blob capability, even without new blob files. Ordinary Blob v2 writes without this opt-in do not activate it. Once activated, removing the opt-in, removing Blob fields, or restoring an older snapshot does not clear it. Before activation, all maintenance clients must support Managed Blobs: the flag cannot revoke old handles or prevent older clients from running cleanup through an unflagged historical snapshot. See [client compatibility](../../guide/blob.md#managed-objects-and-client-compatibility). diff --git a/protos/table.proto b/protos/table.proto index 6902bd954e5..01e61ca0a3f 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -469,9 +469,10 @@ message IndexMetadata { * fragment IDs. An empty map means no mapping. Unmapped IDs keep their * value. Each stored ID is translated once. * - * Applies to fragment references in the segment, including physical row - * addresses, BTree, ZoneMap, and BloomFilter. A row address keeps its row - * offset. Stable logical row IDs and user column values are not translated. + * Applies to every fragment ID referenced by the segment's files, such as the + * fragment half of a physical row address or a zone's fragment ID. A row + * address keeps its row offset. Stable logical row IDs and user column values + * are not translated. * * Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is * reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index 0ea1ee02caa..8f5f2250b1a 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1270,9 +1270,10 @@ pub struct IndexMetadata { /// fragment IDs. An empty map means no mapping. Unmapped IDs keep their /// value. Each stored ID is translated once. /// - /// Applies to fragment references in the segment, including physical row - /// addresses, BTree, ZoneMap, and BloomFilter. A row address keeps its row - /// offset. Stable logical row IDs and user column values are not translated. + /// Applies to every fragment ID referenced by the segment's files, such as the + /// fragment half of a physical row address or a zone's fragment ID. A row + /// address keeps its row offset. Stable logical row IDs and user column values + /// are not translated. /// /// Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is /// reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not From a731ad002606fcd705a122756d06b08a804b9110 Mon Sep 17 00:00:00 2001 From: geruh Date: Tue, 17 Nov 2026 12:09:11 -0800 Subject: [PATCH 7/7] address review wording on fragment_bitmap and referenced fragment IDs Co-authored-by: Drew --- docs/src/format/index/index.md | 2 +- protos/table.proto | 11 +++++------ rust/lance-table/src/pb/lance.table.rs | 11 +++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/src/format/index/index.md b/docs/src/format/index/index.md index 859da8260cd..f23ba42a92a 100644 --- a/docs/src/format/index/index.md +++ b/docs/src/format/index/index.md @@ -273,7 +273,7 @@ A segment whose files store stable row IDs must not carry local fragment aliases. A commit retry can reassign row IDs as well as fragment IDs, and the map cannot translate row IDs. -`fragment_bitmap` must hold committed fragment IDs, before FRI remapping. +`fragment_bitmap` must hold committed dataset fragment IDs, not local IDs. When a commit or rebase changes the committed ID of a fragment referenced through `local_fragment_aliases`, it must update `fragment_bitmap` and the aliases together. The index files do not need to be rewritten. For example, diff --git a/protos/table.proto b/protos/table.proto index 01e61ca0a3f..5bfacaf47c7 100644 --- a/protos/table.proto +++ b/protos/table.proto @@ -371,10 +371,9 @@ message IndexMetadata { /* A bitmap of the included fragment ids. * - * Stores committed dataset fragment IDs (before FRI remapping), not local - * fragment IDs stored inside index files. When `local_fragment_aliases` is - * used, a commit or rebase updates this bitmap and the aliases together - * without rewriting the index files. + * Stores committed dataset fragment IDs, not local IDs stored inside index + * files. When `local_fragment_aliases` is used, a commit or rebase updates + * this bitmap and the aliases together without rewriting the index files. * * This may by used to determine how much of the dataset is covered by the * index. This information can be retrieved from the dataset by looking at @@ -475,8 +474,8 @@ message IndexMetadata { * are not translated. * * Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is - * reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not - * resolve to the same final fragment ID. + * reserved for RowAddress::TOMBSTONE_FRAG. Two referenced fragment IDs must + * not resolve to the same final fragment ID. * * Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and * writer feature flags while nonempty. Both bits are cleared when no diff --git a/rust/lance-table/src/pb/lance.table.rs b/rust/lance-table/src/pb/lance.table.rs index 8f5f2250b1a..75b9adb7146 100644 --- a/rust/lance-table/src/pb/lance.table.rs +++ b/rust/lance-table/src/pb/lance.table.rs @@ -1179,10 +1179,9 @@ pub struct IndexMetadata { pub dataset_version: u64, /// A bitmap of the included fragment ids. /// - /// Stores committed dataset fragment IDs (before FRI remapping), not local - /// fragment IDs stored inside index files. When `local_fragment_aliases` is - /// used, a commit or rebase updates this bitmap and the aliases together - /// without rewriting the index files. + /// Stores committed dataset fragment IDs, not local IDs stored inside index + /// files. When `local_fragment_aliases` is used, a commit or rebase updates + /// this bitmap and the aliases together without rewriting the index files. /// /// This may by used to determine how much of the dataset is covered by the /// index. This information can be retrieved from the dataset by looking at @@ -1276,8 +1275,8 @@ pub struct IndexMetadata { /// are not translated. /// /// Keys and values must be less than 2^32 - 1. u32::MAX (2^32 - 1) is - /// reserved for RowAddress::TOMBSTONE_FRAG. Two referenced IDs must not - /// resolve to the same final fragment ID. + /// reserved for RowAddress::TOMBSTONE_FRAG. Two referenced fragment IDs must + /// not resolve to the same final fragment ID. /// /// Requires flag 1 << 20 (FLAG_LOCAL_FRAGMENT_ALIASES) in both reader and /// writer feature flags while nonempty. Both bits are cleared when no