pub struct LanceStore {
db_path: PathBuf,
embedding_dim: usize,
embedding_model: Option<String>,
connection: RwLock<Option<Connection>>,
chunks_table: RwLock<Option<Table>>,
files_table: RwLock<Option<Table>>,
}Expand description
LanceDB-based vector store.
Fields§
§db_path: PathBufPath to the LanceDB database
embedding_dim: usizeEmbedding dimension
embedding_model: Option<String>Embedder model id that should match this index, when known.
connection: RwLock<Option<Connection>>Database connection (lazy initialized)
chunks_table: RwLock<Option<Table>>Chunks table handle
files_table: RwLock<Option<Table>>Files table handle
Implementations§
Source§impl LanceStore
impl LanceStore
Sourcepub fn new(db_path: PathBuf, embedding_dim: usize) -> Self
pub fn new(db_path: PathBuf, embedding_dim: usize) -> Self
Create a new LanceStore.
embedding_dim must come from Embedder::dimension at the call site.
Opening an existing index whose vector column width differs fails in init.
Sourcepub fn with_embedding_model(self, model: impl Into<String>) -> Self
pub fn with_embedding_model(self, model: impl Into<String>) -> Self
Record the embedder model id in the schema sidecar.
Sourcepub fn embedding_dim(&self) -> usize
pub fn embedding_dim(&self) -> usize
Get the embedding dimension.
Sourcefn stored_embedding_dim(schema: &Schema) -> Result<usize, StoreError>
fn stored_embedding_dim(schema: &Schema) -> Result<usize, StoreError>
Width of the chunks vector FixedSizeList.
fn ensure_embedding_dim_matches( &self, schema: &Schema, ) -> Result<(), StoreError>
Sourcepub(crate) fn should_build_ann_index(row_count: usize) -> bool
pub(crate) fn should_build_ann_index(row_count: usize) -> bool
Whether the table is large enough for Lance IVF-PQ training.
Sourcepub(crate) fn should_refresh_ann_index(unindexed_rows: usize) -> bool
pub(crate) fn should_refresh_ann_index(unindexed_rows: usize) -> bool
Refresh IVF-PQ once the unindexed tail is large enough to train another sample.
Sourcepub(crate) fn ann_index_covers_metric(metric: DistanceMetric) -> bool
pub(crate) fn ann_index_covers_metric(metric: DistanceMetric) -> bool
ANN is trained as cosine; other metrics must not use the index.
Sourcepub(crate) fn ann_index_is_cosine(distance_type: Option<DistanceType>) -> bool
pub(crate) fn ann_index_is_cosine(distance_type: Option<DistanceType>) -> bool
Reuse/refresh only a cosine-trained vector index.
async fn vector_index_name(table: &Table) -> Option<String>
async fn refresh_vector_index(table: &Table, index_name: &str)
Sourceasync fn ensure_vector_index(&self) -> Result<(), StoreError>
async fn ensure_vector_index(&self) -> Result<(), StoreError>
Best-effort IVF-PQ on vector. Small tables keep exact scan.
Existing cosine indexes are incrementally refreshed after large appends.
A non-cosine vector index is dropped and replaced when the table is large enough.
Sourceasync fn get_connection(&self) -> Result<Connection, StoreError>
async fn get_connection(&self) -> Result<Connection, StoreError>
Get or create connection.
Sourcefn chunks_schema(&self) -> Schema
fn chunks_schema(&self) -> Schema
Build chunks table schema.
Sourcefn files_schema(&self) -> Schema
fn files_schema(&self) -> Schema
Build files table schema.
Sourceasync fn get_chunks_table(&self) -> Result<Table, StoreError>
async fn get_chunks_table(&self) -> Result<Table, StoreError>
Get or open chunks table.
Sourceasync fn get_files_table(&self) -> Result<Table, StoreError>
async fn get_files_table(&self) -> Result<Table, StoreError>
Get or open files table.
fn schema_sidecar_path(&self) -> PathBuf
async fn read_schema_sidecar(&self) -> Option<u32>
async fn write_schema_sidecar(&self, version: u32) -> Result<(), StoreError>
fn schema_migration_failed_message( db_path: &Path, error: &impl Display, ) -> String
Sourceasync fn ensure_chunks_schema_v2(&self) -> Result<(), StoreError>
async fn ensure_chunks_schema_v2(&self) -> Result<(), StoreError>
Detect a pre-v2 chunks table, add scope columns, and backfill from file_path.
--force rewrites index-root-relative dir_path on new upserts; it cannot
add Lance columns. This path is what existing indexes need on upgrade.
async fn backfill_scope_columns(&self) -> Result<(), StoreError>
Sourcefn chunks_to_batch(&self, chunks: &[Chunk]) -> Result<RecordBatch, StoreError>
fn chunks_to_batch(&self, chunks: &[Chunk]) -> Result<RecordBatch, StoreError>
Convert chunks to Arrow RecordBatch.
Sourcefn file_to_batch(&self, record: &FileRecord) -> Result<RecordBatch, StoreError>
fn file_to_batch(&self, record: &FileRecord) -> Result<RecordBatch, StoreError>
Convert file record to Arrow RecordBatch.
Sourceasync fn chunk_filter_sql(
&self,
filters: &[SearchFilter],
) -> Result<Option<String>, StoreError>
async fn chunk_filter_sql( &self, filters: &[SearchFilter], ) -> Result<Option<String>, StoreError>
Combine chunk-column filters with source-file modified_at constraints.
Sourceasync fn modified_at_path_predicate(
&self,
filters: &[SearchFilter],
) -> Result<Option<String>, StoreError>
async fn modified_at_path_predicate( &self, filters: &[SearchFilter], ) -> Result<Option<String>, StoreError>
Resolve ModifiedAfter / ModifiedBefore against the files table.
Trait Implementations§
Source§impl VectorStore for LanceStore
impl VectorStore for LanceStore
Source§fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn upsert_chunks<'life0, 'life1, 'async_trait>(
&'life0 self,
chunks: &'life1 [Chunk],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upsert_chunks<'life0, 'life1, 'async_trait>(
&'life0 self,
chunks: &'life1 [Chunk],
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn search<'life0, 'async_trait>(
&'life0 self,
query: SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search<'life0, 'async_trait>(
&'life0 self,
query: SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn hybrid_search<'life0, 'async_trait>(
&'life0 self,
query: SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn hybrid_search<'life0, 'async_trait>(
&'life0 self,
query: SearchQuery,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn delete_by_file_path<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_by_file_path<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn update_file_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update_file_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn get_chunks_for_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Chunk>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_chunks_for_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Chunk>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<FileRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_file<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Option<FileRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn upsert_file<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 FileRecord,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upsert_file<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 FileRecord,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StoreStats, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StoreStats, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_all_chunks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Chunk>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_chunks<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Chunk>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_all_files<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<FileRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_files<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<FileRecord>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for LanceStore
impl !RefUnwindSafe for LanceStore
impl !UnwindSafe for LanceStore
impl Send for LanceStore
impl Sync for LanceStore
impl Unpin for LanceStore
impl UnsafeUnpin for LanceStore
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2where
T: SharedNiching<N1, N2>,
N1: Niching<T>,
N2: Niching<T>,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.