pub struct Bm25Cache { /* private fields */ }Expand description
A lazily-built, shared Bm25Index over a store’s whole chunk corpus.
Building the index reads every chunk, so a retriever that rebuilt it per
query paid that cost several times for a single question — hybrid runs one
keyword search per query, multi-query one per rewrite. The cache builds it
once and hands out an Arc.
Freshness is checked on every use against a cheap store fingerprint (the
document and chunk counts, one COUNT(*) each) plus a generation counter
that Bm25Cache::invalidate bumps — the pipeline calls that on every
write, which is what catches an edit that happens to leave the counts
unchanged. A different process writing to the same database is only caught
by the counts, so a shared store can serve one stale result after such a
same-count edit.
Implementations§
Source§impl Bm25Cache
impl Bm25Cache
Sourcepub fn invalidate(&self)
pub fn invalidate(&self)
Drop the cached index. Call after any write to the store.
Sourcepub async fn index(
&self,
store: &Arc<dyn VectorStore>,
params: Bm25Params,
) -> Result<Arc<Bm25Index>>
pub async fn index( &self, store: &Arc<dyn VectorStore>, params: Bm25Params, ) -> Result<Arc<Bm25Index>>
The index for store, rebuilding it if the corpus or params moved.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Bm25Cache
impl !RefUnwindSafe for Bm25Cache
impl Send for Bm25Cache
impl Sync for Bm25Cache
impl Unpin for Bm25Cache
impl UnsafeUnpin for Bm25Cache
impl UnwindSafe for Bm25Cache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().