OmenFile

Struct OmenFile 

Source
pub struct OmenFile { /* private fields */ }
Expand description

OmenFile - single-file vector database

Storage layer for vectors, metadata, and serialized HNSW index. Graph traversal is handled by HNSWIndex in the vector layer.

Implementations§

Source§

impl OmenFile

Source

pub fn compute_omen_path(path: &Path) -> PathBuf

Compute .omen path by appending extension (preserves full filename)

Handles filenames with multiple dots (e.g., test.db_64test.db_64.omen) by appending .omen rather than replacing the extension.

Source

pub fn create(path: impl AsRef<Path>, dimensions: u32) -> Result<Self>

Create a new .omen database

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open an existing .omen database

Source

pub fn insert( &mut self, id: &str, vector: &[f32], metadata: Option<&[u8]>, ) -> Result<()>

Insert a vector

Note: Graph management (HNSW) is handled by HNSWIndex in the vector layer. This method only handles storage: WAL, vectors, metadata.

Source

pub fn search(&self, query: &[f32], k: usize) -> Vec<(String, f32)>

Search for k nearest neighbors

Source

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

Delete a vector by ID

Source

pub fn len(&self) -> u64

Get vector count

Source

pub fn is_empty(&self) -> bool

Check if empty

Source

pub fn dimensions(&self) -> u32

Get dimensions

Source

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

Checkpoint - compact WAL into main file

Source§

impl OmenFile

Source

pub fn put_vector(&mut self, id: usize, vector: &[f32]) -> Result<()>

Store a vector by internal index

Source

pub fn get_vector(&self, id: usize) -> Result<Option<Vec<f32>>>

Get a vector by internal index

Source

pub fn put_metadata(&mut self, id: usize, metadata: &JsonValue) -> Result<()>

Store metadata for a vector (as JSON)

Source

pub fn get_metadata(&self, id: usize) -> Result<Option<JsonValue>>

Get metadata for a vector (as JSON)

Source

pub fn put_id_mapping(&mut self, string_id: &str, index: usize) -> Result<()>

Store string ID to internal index mapping

Source

pub fn get_id_mapping(&self, string_id: &str) -> Result<Option<usize>>

Get internal index for a string ID

Source

pub fn get_string_id(&self, index: usize) -> Result<Option<String>>

Get string ID for an internal index (reverse lookup)

Source

pub fn delete_id_mapping(&mut self, string_id: &str) -> Result<()>

Delete string ID mapping

Source

pub fn put_config(&mut self, key: &str, value: u64) -> Result<()>

Store configuration value

Source

pub fn get_config(&self, key: &str) -> Result<Option<u64>>

Get configuration value

Source

pub fn load_all_vectors(&self) -> Result<Vec<(usize, Vec<f32>)>>

Load all vectors from storage

Source

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

Increment vector count in storage

Source

pub fn get_count(&self) -> Result<usize>

Get current vector count

Source

pub fn put_quantization_mode(&mut self, mode: u64) -> Result<()>

Store quantization mode

Mode values: 0=none, 1=sq8, 2=rabitq-4, 3=rabitq-2, 4=rabitq-8

Source

pub fn get_quantization_mode(&self) -> Result<Option<u64>>

Get quantization mode

Returns: 0=none, 1=sq8, 2=rabitq-4, 3=rabitq-2, 4=rabitq-8

Source

pub fn is_quantized(&self) -> Result<bool>

Check if store was created with quantization

Source

pub fn load_all_metadata(&self) -> Result<HashMap<usize, JsonValue>>

Load all metadata from storage

Source

pub fn load_all_id_mappings(&self) -> Result<HashMap<String, usize>>

Load all ID mappings from storage

Source

pub fn put_deleted(&mut self, id: usize) -> Result<()>

Mark a vector as deleted (tombstone)

Source

pub fn is_deleted(&self, id: usize) -> Result<bool>

Check if a vector is deleted

Source

pub fn remove_deleted(&mut self, id: usize) -> Result<()>

Remove deleted marker (for re-insertion)

Source

pub fn load_all_deleted(&self) -> Result<HashMap<usize, bool>>

Load all deleted IDs from storage

Source

pub fn put_hnsw_index(&mut self, bytes: Vec<u8>)

Store serialized HNSW index bytes

The bytes are persisted on the next checkpoint/flush. VectorStore serializes HNSWIndex and stores it here.

Source

pub fn get_hnsw_index(&self) -> Option<&[u8]>

Get serialized HNSW index bytes (if present)

Returns the bytes previously stored by put_hnsw_index(), or loaded from disk on open.

Source

pub fn has_hnsw_index(&self) -> bool

Check if HNSW index is stored

Source

pub fn set_hnsw_params(&mut self, m: u16, ef_construction: u16, ef_search: u16)

Update HNSW parameters in the header

These values are persisted to disk on the next checkpoint/flush.

Source

pub fn path(&self) -> &Path

Get storage path

Source

pub fn header(&self) -> &OmenHeader

Get reference to the header

Source

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

Flush all pending writes to disk

Source

pub fn put_batch( &mut self, items: Vec<(usize, String, Vec<f32>, JsonValue)>, ) -> Result<()>

Batch set vectors with metadata and ID mappings

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Fruit for T
where T: Send + Downcast,