Skip to main content

Storage

Struct Storage 

Source
pub struct Storage {
    pub vectors: MmapVectorStore,
    pub wal: WriteAheadLog,
    pub metadata: MetadataStore,
    pub index: AnyIndex,
    pub sparse: SparseIndex,
    pub hybrid: HybridEngine,
    pub planner: QueryPlanner,
    pub config: CollectionConfig,
    /* private fields */
}

Fields§

§vectors: MmapVectorStore§wal: WriteAheadLog§metadata: MetadataStore§index: AnyIndex§sparse: SparseIndex§hybrid: HybridEngine§planner: QueryPlanner§config: CollectionConfig

Implementations§

Source§

impl Storage

Source

pub fn create(data_dir: &Path, config: &CollectionConfig) -> Result<Self>

Source

pub fn open(data_dir: &Path, collection_name: &str) -> Result<Self>

Source

pub fn upsert(&mut self, record: VectorRecord) -> Result<UpsertResult>

Source

pub fn bulk_upsert(&mut self, records: Vec<VectorRecord>) -> Result<usize>

Bulk-insert new records efficiently: append all vectors, write the WAL in one batched fsync, insert metadata in one transaction, then build the dense (and sparse) index once — instead of the per-insert index rebuilds upsert triggers. Intended for loading a fresh/large collection.

Assumes the ids are new (uses append semantics). A final checkpoint truncates the WAL, since the data is durable in the vector store, the metadata db, and the saved index.

Source

pub fn delete(&mut self, id: &VectorId) -> Result<()>

Source

pub fn search(&self, query: &Vector, k: usize) -> Result<Vec<SearchResult>>

Search the dense HNSW index and hydrate results with metadata payloads.

Source

pub fn search_sparse(&self, query: &str, k: usize) -> Result<Vec<SearchResult>>

Full-text BM25 search using the sparse index.

Source

pub fn execute_sql(&self, sql: &str) -> Result<Vec<SearchResult>>

Parse and execute a SQL string against this collection.

The SQL must include a VECTOR_SIM(col, [...]) op threshold predicate. Optional scalar equality conditions (AND field = 'value') are applied as post-scan metadata filters.

Route a SearchRequest through the query planner and execute the resulting physical plan.

This is the primary search entry point for callers that want the full planner pipeline (cost model, hybrid decision, candidate oversampling).

Source

pub fn search_dense( &self, query_vector: &Vector, k: usize, ) -> Result<Vec<SearchResult>>

Dense HNSW search with full metadata hydration.

Equivalent to search but makes the intent explicit and is used by callers that distinguish dense vs hybrid paths.

Source

pub fn search_dense_filtered( &self, query: &Vector, k: usize, filter: &Value, ) -> Result<Vec<SearchResult>>

Dense k-NN search restricted to records whose payload matches filter, with predicate pushdown.

When the filter is selective (the allowed set is small relative to the collection), candidates are generated from the filter: an exact, full-precision brute-force scan over only the matching vectors. This never scores the excluded majority, so a 95%-eliminating filter costs roughly 5% of the work — and is exact, unlike oversample-then-discard.

When the filter is weakly selective, it falls back to an ANN search with a post-filter (few candidates are dropped, so recall stays high).

Source

pub fn search_hybrid( &self, query_vector: Option<&Vector>, query_text: Option<&str>, k: usize, alpha: f32, strategy: FusionStrategy, ) -> Result<Vec<SearchResult>>

Two-stage hybrid retrieval pipeline.

At least one of query_vector / query_text must be provided.

Stage 1 — Dense: fetch k * 5 HNSW candidates (or empty if no vector). Stage 2 — Sparse: re-score dense candidates with BM25 (or full-corpus search when no dense candidates exist). Stage 3 — Fusion: combine via strategy and alpha. Stage 4 — Hydrate: populate payload and text from metadata.

Source

pub fn rebuild_index(&mut self) -> Result<()>

Rebuild the dense index from the current metadata + mmap store. Also rebuilds the sparse index from stored text payloads.

Source

pub fn save_indexes(&self) -> Result<()>

Persist both the dense index and the sparse index to disk.

Source

pub fn recover_from_wal(&mut self) -> Result<usize>

Source

pub fn checkpoint(&mut self) -> Result<()>

Source

pub fn stats(&self) -> Result<IndexStats>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more