feat: expose optimize index api (#602)

expose `optimize_index` api.
This commit is contained in:
Rob Meng
2023-10-25 19:40:23 -04:00
committed by GitHub
parent f3cf986777
commit 28b02fb72a

View File

@@ -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