pub struct Db { /* private fields */ }Expand description
A vecdb database: a handle to a directory that holds one or more
collections. Cheap to clone-by-reopen; owns no file handles itself —
each Collection it hands out owns its own storage.
Implementations§
Source§impl Db
impl Db
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open (creating if absent) a database rooted at path.
path is a directory. A .vecdb suffix is conventional but not
required — the directory holds the per-collection files.
Sourcepub fn create_collection(
&self,
name: impl Into<String>,
dimension: usize,
) -> Result<Collection>
pub fn create_collection( &self, name: impl Into<String>, dimension: usize, ) -> Result<Collection>
Create a new collection with default HNSW config. Errors if a collection of that name already exists.
Sourcepub fn create_collection_with(
&self,
config: CollectionConfig,
) -> Result<Collection>
pub fn create_collection_with( &self, config: CollectionConfig, ) -> Result<Collection>
Create a new collection from a full CollectionConfig.
Sourcepub fn create_collection_quantized(
&self,
name: impl Into<String>,
dimension: usize,
) -> Result<Collection>
pub fn create_collection_quantized( &self, name: impl Into<String>, dimension: usize, ) -> Result<Collection>
Create a new collection whose in-memory index uses int8 scalar quantization (~4× smaller index; on-disk vectors stay float32).
Sourcepub fn create_collection_binary(
&self,
name: impl Into<String>,
dimension: usize,
) -> Result<Collection>
pub fn create_collection_binary( &self, name: impl Into<String>, dimension: usize, ) -> Result<Collection>
Create a new collection whose in-memory index uses 1-bit binary quantization (~32× smaller; coarse Hamming distance — best paired with a full-precision rerank of top candidates).
Sourcepub fn collection(&self, name: &str) -> Result<Collection>
pub fn collection(&self, name: &str) -> Result<Collection>
Open an existing collection. Errors with CollectionNotFound if absent.
Sourcepub fn open_or_create(&self, name: &str, dimension: usize) -> Result<Collection>
pub fn open_or_create(&self, name: &str, dimension: usize) -> Result<Collection>
Open the collection if it exists, otherwise create it with default
HNSW config at dimension.
Sourcepub fn collection_exists(&self, name: &str) -> bool
pub fn collection_exists(&self, name: &str) -> bool
Whether a collection with this name exists on disk (by its .db file).
Sourcepub fn list_collections(&self) -> Result<Vec<String>>
pub fn list_collections(&self) -> Result<Vec<String>>
Sorted names of all collections in this database (scans *.db files).
Sourcepub fn drop_collection(&self, name: &str) -> Result<()>
pub fn drop_collection(&self, name: &str) -> Result<()>
Delete a collection and all its files from disk.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Db
impl RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl UnwindSafe for Db
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
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> ⓘ
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