pub struct SqliteEmbeddingIndex { /* private fields */ }Expand description
The memory_embeddings table, searched exactly (every live vector is
scored).
Decoded vectors are kept in memory per filter and reused until the table
changes. A trigger installed by crate::sqlite::migrate bumps
memory_embedding_generation on every insert, update or delete, whoever
writes the row (this index, retention, a wipe, another process), and a
search first compares that number with the one its vectors were loaded at.
Without the generation table (a database crate::sqlite::migrate has
not seen) every search reads the table, as before.
Clones share the cache, so hold one index per database and clone it.
Implementations§
Source§impl SqliteEmbeddingIndex
impl SqliteEmbeddingIndex
pub fn new(pool: SqlitePool) -> Self
Trait Implementations§
Source§impl Clone for SqliteEmbeddingIndex
impl Clone for SqliteEmbeddingIndex
Source§impl EmbeddingIndex for SqliteEmbeddingIndex
impl EmbeddingIndex for SqliteEmbeddingIndex
fn upsert<'life0, 'async_trait>(
&'life0 self,
item: EmbeddingItem,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 [f32],
filter: &'life2 EmbeddingSearchFilter,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddingHit>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_stale<'life0, 'life1, 'async_trait>(
&'life0 self,
owner: &'life1 MemoryOwner,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn purge_stale<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteEmbeddingIndex
impl !UnwindSafe for SqliteEmbeddingIndex
impl Forget for SqliteEmbeddingIndex
impl Freeze for SqliteEmbeddingIndex
impl Move for SqliteEmbeddingIndex
impl Send for SqliteEmbeddingIndex
impl Sync for SqliteEmbeddingIndex
impl Unpin for SqliteEmbeddingIndex
impl UnsafeUnpin for SqliteEmbeddingIndexwhere
*const ArcInner<PoolInner<Sqlite>> is !null: UnsafeUnpin,
PhantomData<ArcInner<PoolInner<Sqlite>>>: UnsafeUnpin,
*const ArcInner<Mutex<HashMap<CacheKey, Arc<VectorSet>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<HashMap<CacheKey, Arc<VectorSet>>>>>: UnsafeUnpin,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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> ⓘ
Converts
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> ⓘ
Converts
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