Skip to content

Commit fff336c

Browse files
westonpaceclaude
andauthored
docs(index): document public API of LogicalScalarIndex (#6804)
Add rustdoc to the LogicalScalarIndex struct and the two public loader functions (open_named_scalar_index, scalar_index_fragment_bitmap), covering when the wrapper is used, the same-index-type constraint, how SearchResult precision is combined across segments, and the read-only remap/update behavior. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bc2d137 commit fff336c

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

rust/lance/src/index/scalar_logical.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ use crate::dataset::Dataset;
2323
use crate::index::scalar::fetch_index_details;
2424
use crate::index::{DatasetIndexExt, DatasetIndexInternalExt};
2525

26+
/// Query-time view that exposes several physical scalar index segments as a single [`ScalarIndex`].
27+
///
28+
/// A named scalar index can be built incrementally, producing multiple physical segments that
29+
/// each cover a disjoint set of fragments. When such an index is opened, the loader bundles
30+
/// the segments into a `LogicalScalarIndex` so the scanner can treat them as one index: queries
31+
/// are fanned out to every segment in parallel and the row-address results are unioned together.
32+
///
33+
/// All segments must share the same [`IndexType`]; mixing types is rejected at construction.
34+
/// Per-segment [`SearchResult`] precision is preserved when combining: a union of `Exact`
35+
/// results stays `Exact`, a union containing `AtMost` results yields `AtMost`, and a union
36+
/// containing `AtLeast` results yields `AtLeast`. Combining `AtMost` and `AtLeast` segments in
37+
/// the same query is not supported.
38+
///
39+
/// This is a read-only wrapper. [`ScalarIndex::remap`] and [`ScalarIndex::update`] both return
40+
/// an error — callers must rebuild the index to consolidate segments before mutating it.
2641
#[derive(Debug)]
2742
pub struct LogicalScalarIndex {
2843
name: String,
@@ -280,6 +295,11 @@ fn union_fragment_bitmaps(indices: &[IndexMetadata], index_name: &str) -> Result
280295
Ok(combined)
281296
}
282297

298+
/// Return the union of fragment bitmaps across every usable segment of a named scalar index.
299+
///
300+
/// Only segments whose fragment bitmap intersects the dataset's current fragment set are
301+
/// considered. Returns `Ok(None)` when no such segment exists, `Ok(Some(bitmap))` otherwise.
302+
/// Errors if the segments disagree on their underlying index type.
283303
pub async fn scalar_index_fragment_bitmap(
284304
dataset: &Dataset,
285305
column: &str,
@@ -296,6 +316,13 @@ pub async fn scalar_index_fragment_bitmap(
296316
}
297317
}
298318

319+
/// Open a named scalar index, transparently bundling multiple segments when present.
320+
///
321+
/// Loads every segment registered under `index_name` whose fragment bitmap intersects the
322+
/// dataset. If exactly one usable segment exists it is returned directly; if multiple exist
323+
/// they are wrapped in a [`LogicalScalarIndex`] so the caller sees a single [`ScalarIndex`].
324+
/// Errors if no usable segment exists (the scanner planned a query against an index that is
325+
/// not present) or if the segments mix incompatible types.
299326
pub async fn open_named_scalar_index(
300327
dataset: &Dataset,
301328
column: &str,

0 commit comments

Comments
 (0)