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
impl OmenFile
Sourcepub fn compute_omen_path(path: &Path) -> PathBuf
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_64 → test.db_64.omen)
by appending .omen rather than replacing the extension.
Sourcepub fn create(path: impl AsRef<Path>, dimensions: u32) -> Result<Self>
pub fn create(path: impl AsRef<Path>, dimensions: u32) -> Result<Self>
Create a new .omen database
Sourcepub fn insert(
&mut self,
id: &str,
vector: &[f32],
metadata: Option<&[u8]>,
) -> Result<()>
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.
Sourcepub fn search(&self, query: &[f32], k: usize) -> Vec<(String, f32)>
pub fn search(&self, query: &[f32], k: usize) -> Vec<(String, f32)>
Search for k nearest neighbors
Sourcepub fn dimensions(&self) -> u32
pub fn dimensions(&self) -> u32
Get dimensions
Sourcepub fn checkpoint(&mut self) -> Result<()>
pub fn checkpoint(&mut self) -> Result<()>
Checkpoint - compact WAL into main file
Source§impl OmenFile
impl OmenFile
Sourcepub fn put_vector(&mut self, id: usize, vector: &[f32]) -> Result<()>
pub fn put_vector(&mut self, id: usize, vector: &[f32]) -> Result<()>
Store a vector by internal index
Sourcepub fn put_metadata(&mut self, id: usize, metadata: &JsonValue) -> Result<()>
pub fn put_metadata(&mut self, id: usize, metadata: &JsonValue) -> Result<()>
Store metadata for a vector (as JSON)
Sourcepub fn get_metadata(&self, id: usize) -> Result<Option<JsonValue>>
pub fn get_metadata(&self, id: usize) -> Result<Option<JsonValue>>
Get metadata for a vector (as JSON)
Sourcepub fn put_id_mapping(&mut self, string_id: &str, index: usize) -> Result<()>
pub fn put_id_mapping(&mut self, string_id: &str, index: usize) -> Result<()>
Store string ID to internal index mapping
Sourcepub fn get_id_mapping(&self, string_id: &str) -> Result<Option<usize>>
pub fn get_id_mapping(&self, string_id: &str) -> Result<Option<usize>>
Get internal index for a string ID
Sourcepub fn get_string_id(&self, index: usize) -> Result<Option<String>>
pub fn get_string_id(&self, index: usize) -> Result<Option<String>>
Get string ID for an internal index (reverse lookup)
Sourcepub fn delete_id_mapping(&mut self, string_id: &str) -> Result<()>
pub fn delete_id_mapping(&mut self, string_id: &str) -> Result<()>
Delete string ID mapping
Sourcepub fn increment_count(&mut self) -> Result<usize>
pub fn increment_count(&mut self) -> Result<usize>
Increment vector count in storage
Sourcepub fn put_quantization_mode(&mut self, mode: u64) -> Result<()>
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
Sourcepub fn get_quantization_mode(&self) -> Result<Option<u64>>
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
Sourcepub fn is_quantized(&self) -> Result<bool>
pub fn is_quantized(&self) -> Result<bool>
Check if store was created with quantization
Sourcepub fn load_all_metadata(&self) -> Result<HashMap<usize, JsonValue>>
pub fn load_all_metadata(&self) -> Result<HashMap<usize, JsonValue>>
Load all metadata from storage
Sourcepub fn load_all_id_mappings(&self) -> Result<HashMap<String, usize>>
pub fn load_all_id_mappings(&self) -> Result<HashMap<String, usize>>
Load all ID mappings from storage
Sourcepub fn put_deleted(&mut self, id: usize) -> Result<()>
pub fn put_deleted(&mut self, id: usize) -> Result<()>
Mark a vector as deleted (tombstone)
Sourcepub fn is_deleted(&self, id: usize) -> Result<bool>
pub fn is_deleted(&self, id: usize) -> Result<bool>
Check if a vector is deleted
Sourcepub fn remove_deleted(&mut self, id: usize) -> Result<()>
pub fn remove_deleted(&mut self, id: usize) -> Result<()>
Remove deleted marker (for re-insertion)
Sourcepub fn load_all_deleted(&self) -> Result<HashMap<usize, bool>>
pub fn load_all_deleted(&self) -> Result<HashMap<usize, bool>>
Load all deleted IDs from storage
Sourcepub fn put_hnsw_index(&mut self, bytes: Vec<u8>)
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.
Sourcepub fn get_hnsw_index(&self) -> Option<&[u8]>
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.
Sourcepub fn has_hnsw_index(&self) -> bool
pub fn has_hnsw_index(&self) -> bool
Check if HNSW index is stored
Sourcepub fn set_hnsw_params(&mut self, m: u16, ef_construction: u16, ef_search: u16)
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.
Sourcepub fn header(&self) -> &OmenHeader
pub fn header(&self) -> &OmenHeader
Get reference to the header
Auto Trait Implementations§
impl Freeze for OmenFile
impl RefUnwindSafe for OmenFile
impl Send for OmenFile
impl Sync for OmenFile
impl Unpin for OmenFile
impl UnwindSafe for OmenFile
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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