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
1 change: 1 addition & 0 deletions .claude/scheduled_tasks.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sessionId":"23aa895c-8c08-462b-ae20-e4ad399e466f","pid":1,"procStart":"52028919","acquiredAt":1782134409076}
2 changes: 1 addition & 1 deletion rust/lance-index/benches/geo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use geoarrow_schema::Dimension;
use lance_core::cache::LanceCache;
use lance_core::{Error, ROW_ID};
use lance_index::scalar::lance_format::LanceIndexStore;
use lance_index::scalar::registry::ScalarIndexPlugin;
use lance_index::scalar::registry::BasicTrainer;
use lance_index::scalar::rtree::{BoundingBox, RTreeIndex, RTreeIndexPlugin, RTreeTrainingRequest};
use lance_index::scalar::{GeoQuery, RelationQuery, ScalarIndex};
use lance_io::object_store::ObjectStore;
Expand Down
59 changes: 33 additions & 26 deletions rust/lance-index/src/scalar/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use crate::{
CreatedIndex, UpdateCriteria,
expression::SargableQueryParser,
registry::{
ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
BasicTrainer, ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
VALUE_COLUMN_NAME,
},
},
Expand Down Expand Up @@ -1676,11 +1676,7 @@ pub async fn merge_bitmap_indices(
}

#[async_trait]
impl ScalarIndexPlugin for BitmapIndexPlugin {
fn name(&self) -> &str {
"Bitmap"
}

impl BasicTrainer for BitmapIndexPlugin {
fn new_training_request(
&self,
params: &str,
Expand All @@ -1699,26 +1695,6 @@ impl ScalarIndexPlugin for BitmapIndexPlugin {
Ok(Box::new(BitmapTrainingRequest::new(params)))
}

fn provides_exact_answer(&self) -> bool {
true
}

fn version(&self) -> u32 {
BITMAP_INDEX_VERSION
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
Some(Box::new(SargableQueryParser::new(
index_name,
self.name().to_string(),
false,
)))
}

async fn train_index(
&self,
data: SendableRecordBatchStream,
Expand Down Expand Up @@ -1760,6 +1736,37 @@ impl ScalarIndexPlugin for BitmapIndexPlugin {
files: vec![file],
})
}
}

#[async_trait]
impl ScalarIndexPlugin for BitmapIndexPlugin {
fn basic_trainer(&self) -> Option<&dyn BasicTrainer> {
Some(self)
}

fn name(&self) -> &str {
"Bitmap"
}

fn provides_exact_answer(&self) -> bool {
true
}

fn version(&self) -> u32 {
BITMAP_INDEX_VERSION
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
Some(Box::new(SargableQueryParser::new(
index_name,
self.name().to_string(),
false,
)))
}

/// Load an index from storage
async fn load_index(
Expand Down
19 changes: 13 additions & 6 deletions rust/lance-index/src/scalar/bloomfilter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use crate::scalar::expression::{BloomFilterQueryParser, ScalarQueryParser};
use crate::scalar::registry::{
ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
BasicTrainer, ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
};
use crate::scalar::{
BloomFilterQuery, BuiltinIndexType, CreatedIndex, IndexFile, ScalarIndexParams, UpdateCriteria,
Expand Down Expand Up @@ -995,11 +995,7 @@ impl BloomFilterIndexPlugin {
}

#[async_trait]
impl ScalarIndexPlugin for BloomFilterIndexPlugin {
fn name(&self) -> &str {
"BloomFilter"
}

impl BasicTrainer for BloomFilterIndexPlugin {
fn new_training_request(
&self,
params: &str,
Expand Down Expand Up @@ -1082,6 +1078,13 @@ impl ScalarIndexPlugin for BloomFilterIndexPlugin {
files: vec![file],
})
}
}

#[async_trait]
impl ScalarIndexPlugin for BloomFilterIndexPlugin {
fn basic_trainer(&self) -> Option<&dyn BasicTrainer> {
Some(self)
}

fn provides_exact_answer(&self) -> bool {
false
Expand All @@ -1091,6 +1094,10 @@ impl ScalarIndexPlugin for BloomFilterIndexPlugin {
BLOOMFILTER_INDEX_VERSION
}

fn name(&self) -> &str {
"BloomFilter"
}

fn new_query_parser(
&self,
index_name: String,
Expand Down
61 changes: 35 additions & 26 deletions rust/lance-index/src/scalar/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use crate::{
scalar::{
CreatedIndex, UpdateCriteria,
expression::{SargableQueryParser, ScalarQueryParser},
registry::{ScalarIndexPlugin, TrainingOrdering, TrainingRequest, VALUE_COLUMN_NAME},
registry::{
BasicTrainer, ScalarIndexPlugin, TrainingOrdering, TrainingRequest, VALUE_COLUMN_NAME,
},
},
};
use crate::{metrics::NoOpMetricsCollector, scalar::registry::TrainingCriteria};
Expand Down Expand Up @@ -3202,11 +3204,7 @@ impl TrainingRequest for BTreeTrainingRequest {
pub struct BTreeIndexPlugin;

#[async_trait]
impl ScalarIndexPlugin for BTreeIndexPlugin {
fn name(&self) -> &str {
"BTree"
}

impl BasicTrainer for BTreeIndexPlugin {
fn new_training_request(
&self,
params: &str,
Expand All @@ -3222,26 +3220,6 @@ impl ScalarIndexPlugin for BTreeIndexPlugin {
Ok(Box::new(BTreeTrainingRequest::new(params)))
}

fn provides_exact_answer(&self) -> bool {
true
}

fn version(&self) -> u32 {
BTREE_INDEX_VERSION
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
Some(Box::new(SargableQueryParser::new(
index_name,
self.name().to_string(),
false,
)))
}

async fn train_index(
&self,
data: SendableRecordBatchStream,
Expand Down Expand Up @@ -3286,6 +3264,37 @@ impl ScalarIndexPlugin for BTreeIndexPlugin {
files,
})
}
}

#[async_trait]
impl ScalarIndexPlugin for BTreeIndexPlugin {
fn basic_trainer(&self) -> Option<&dyn BasicTrainer> {
Some(self)
}

fn name(&self) -> &str {
"BTree"
}

fn provides_exact_answer(&self) -> bool {
true
}

fn version(&self) -> u32 {
BTREE_INDEX_VERSION
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
Some(Box::new(SargableQueryParser::new(
index_name,
self.name().to_string(),
false,
)))
}

async fn load_index(
&self,
Expand Down
21 changes: 15 additions & 6 deletions rust/lance-index/src/scalar/fmindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use crate::metrics::MetricsCollector;
use crate::pb;
use crate::scalar::expression::{ScalarQueryParser, TextQueryParser};
use crate::scalar::registry::{
DefaultTrainingRequest, ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
VALUE_COLUMN_NAME,
BasicTrainer, DefaultTrainingRequest, ScalarIndexPlugin, TrainingCriteria, TrainingOrdering,
TrainingRequest, VALUE_COLUMN_NAME,
};
use crate::scalar::{
AnyQuery, BuiltinIndexType, CreatedIndex, IndexFile, IndexStore, OldIndexDataFilter,
Expand Down Expand Up @@ -1676,10 +1676,7 @@ async fn write_empty_fmindex_partition(store: &dyn IndexStore) -> Result<IndexFi
pub struct FMIndexPlugin;

#[async_trait]
impl ScalarIndexPlugin for FMIndexPlugin {
fn name(&self) -> &str {
"Fm"
}
impl BasicTrainer for FMIndexPlugin {
fn new_training_request(
&self,
_params: &str,
Expand Down Expand Up @@ -1713,6 +1710,17 @@ impl ScalarIndexPlugin for FMIndexPlugin {
files,
})
}
}

#[async_trait]
impl ScalarIndexPlugin for FMIndexPlugin {
fn basic_trainer(&self) -> Option<&dyn BasicTrainer> {
Some(self)
}

fn name(&self) -> &str {
"Fm"
}
fn provides_exact_answer(&self) -> bool {
true
}
Expand Down Expand Up @@ -1766,6 +1774,7 @@ mod tests {
use std::sync::Arc;

use crate::scalar::lance_format::LanceIndexStore;
use crate::scalar::registry::BasicTrainer;

#[test]
fn test_fmindex_build_and_search() {
Expand Down
75 changes: 42 additions & 33 deletions rust/lance-index/src/scalar/inverted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ use crate::{
scalar::{
CreatedIndex, ScalarIndex,
expression::{FtsQueryParser, ScalarQueryParser},
registry::{ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest},
registry::{
BasicTrainer, ScalarIndexPlugin, TrainingCriteria, TrainingOrdering, TrainingRequest,
},
},
};

Expand Down Expand Up @@ -193,11 +195,7 @@ impl TrainingRequest for InvertedIndexTrainingRequest {
}

#[async_trait]
impl ScalarIndexPlugin for InvertedIndexPlugin {
fn name(&self) -> &str {
"Inverted"
}

impl BasicTrainer for InvertedIndexPlugin {
fn new_training_request(
&self,
params: &str,
Expand All @@ -219,33 +217,6 @@ impl ScalarIndexPlugin for InvertedIndexPlugin {
Ok(Box::new(InvertedIndexTrainingRequest::new(params)))
}

fn provides_exact_answer(&self) -> bool {
false
}

fn version(&self) -> u32 {
max_supported_fts_format_version().index_version()
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
let Ok(index_details) = _index_details.to_msg::<pbold::InvertedIndexDetails>() else {
return None;
};

if Self::can_accelerate_queries(&index_details) {
Some(Box::new(FtsQueryParser::new(
index_name,
self.name().to_string(),
)))
} else {
None
}
}

/// Train a new index
///
/// The provided data must fulfill all the criteria returned by `training_criteria`.
Expand Down Expand Up @@ -280,6 +251,44 @@ impl ScalarIndexPlugin for InvertedIndexPlugin {
)
.await
}
}

#[async_trait]
impl ScalarIndexPlugin for InvertedIndexPlugin {
fn basic_trainer(&self) -> Option<&dyn BasicTrainer> {
Some(self)
}

fn name(&self) -> &str {
"Inverted"
}

fn provides_exact_answer(&self) -> bool {
false
}

fn version(&self) -> u32 {
max_supported_fts_format_version().index_version()
}

fn new_query_parser(
&self,
index_name: String,
_index_details: &prost_types::Any,
) -> Option<Box<dyn ScalarQueryParser>> {
let Ok(index_details) = _index_details.to_msg::<pbold::InvertedIndexDetails>() else {
return None;
};

if Self::can_accelerate_queries(&index_details) {
Some(Box::new(FtsQueryParser::new(
index_name,
self.name().to_string(),
)))
} else {
None
}
}

/// Load an index from storage
///
Expand Down
Loading
Loading