Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion rust/lance-index-core/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Abstract scalar index traits and types for Lance index plugins

use arrow_array::{BooleanArray, RecordBatch, UInt64Array};
use arrow_schema::Schema;
use arrow_schema::{DataType, Schema};
use async_trait::async_trait;
use bytes::Bytes;
use datafusion::physical_plan::SendableRecordBatchStream;
Expand Down Expand Up @@ -555,6 +555,16 @@ pub trait ScalarIndex: Send + Sync + std::fmt::Debug + Index + DeepSizeOf {
/// with the same configuration on another dataset.
fn derive_index_params(&self) -> Result<ScalarIndexParams>;

/// Returns the value type expected by [`Self::update`], when the index has
/// a durable type contract for its training data.
///
/// Wrapper indices use this to transform new data to the same type as the
/// loaded index instead of inferring a potentially different type from an
/// update batch. Index types without such a contract may return `None`.
fn training_data_type(&self) -> Option<DataType> {
None
}

/// Global `[min, max]` of the indexed column from index metadata, without a
/// scan, or `None` if this index type cannot supply a sound bound. When
/// `Some`, the range is a superset of live values (conservative under
Expand Down
4 changes: 4 additions & 0 deletions rust/lance-index/src/scalar/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,10 @@ impl ScalarIndex for BTreeIndex {
})?;
Ok(ScalarIndexParams::for_builtin(BuiltinIndexType::BTree).with_params(&params))
}

fn training_data_type(&self) -> Option<DataType> {
Some(self.data_type.clone())
}
}

struct BatchStats {
Expand Down
Loading
Loading