diff --git a/rust/vectordb/src/table.rs b/rust/vectordb/src/table.rs index 8073ee29..74b77922 100644 --- a/rust/vectordb/src/table.rs +++ b/rust/vectordb/src/table.rs @@ -20,7 +20,7 @@ use arrow_schema::SchemaRef; use lance::dataset::cleanup::RemovalStats; use lance::dataset::optimize::{compact_files, CompactionMetrics, CompactionOptions}; use lance::dataset::{Dataset, WriteParams}; -use lance::index::IndexType; +use lance::index::{DatasetIndexExt, IndexType}; use lance::io::object_store::WrappingObjectStore; use std::path::Path; @@ -238,8 +238,6 @@ impl Table { /// Create index on the table. pub async fn create_index(&mut self, index_builder: &impl VectorIndexBuilder) -> Result<()> { - use lance::index::DatasetIndexExt; - let mut dataset = self.dataset.as_ref().clone(); dataset .create_index( @@ -257,6 +255,14 @@ impl Table { Ok(()) } + pub async fn optimize_indices(&mut self) -> Result<()> { + let mut dataset = self.dataset.as_ref().clone(); + + dataset.optimize_indices().await?; + + Ok(()) + } + /// Insert records into this Table /// /// # Arguments