pub struct ShardedSparseHandle { /* private fields */ }Implementations§
Source§impl ShardedSparseHandle
impl ShardedSparseHandle
Sourcepub fn create(
base_path: &str,
config: &ShardedSparseConfig,
) -> Result<Self, String>
pub fn create( base_path: &str, config: &ShardedSparseConfig, ) -> Result<Self, String>
Create a new sharded index on a filesystem directory.
Sourcepub fn open(base_path: &str) -> Result<Self, String>
pub fn open(base_path: &str) -> Result<Self, String>
Open an existing sharded index from a filesystem directory.
Sourcepub fn create_with_store<S: BlobStore>(
store: Arc<S>,
name: &str,
cache_base: &Path,
config: &ShardedSparseConfig,
) -> Result<Self, String>
pub fn create_with_store<S: BlobStore>( store: Arc<S>, name: &str, cache_base: &Path, config: &ShardedSparseConfig, ) -> Result<Self, String>
Create a new sharded index whose truth is a blob store; cache_base
holds the disposable local mmap cache.
Sourcepub fn open_with_store<S: BlobStore>(
store: Arc<S>,
name: &str,
cache_base: &Path,
) -> Result<Self, String>
pub fn open_with_store<S: BlobStore>( store: Arc<S>, name: &str, cache_base: &Path, ) -> Result<Self, String>
Open an existing sharded index from a blob store.
pub fn create_with_storage( storage: Box<dyn SparseShardStorage>, config: &ShardedSparseConfig, ) -> Result<Self, String>
pub fn open_with_storage( storage: Box<dyn SparseShardStorage>, ) -> Result<Self, String>
pub fn num_shards(&self) -> usize
pub fn config(&self) -> &ShardedSparseConfig
pub fn is_empty(&self) -> bool
Sourcepub fn shard_for_node_id(&self, node_id: u64) -> Option<usize>
pub fn shard_for_node_id(&self, node_id: u64) -> Option<usize>
Shard holding node_id, if the router saw it inserted.
Sourcepub fn insert(&self, node_id: u64, vector: &SparseVector) -> Result<(), String>
pub fn insert(&self, node_id: u64, vector: &SparseVector) -> Result<(), String>
Route the vector to a shard by its dimensions and queue the insert.
Failures inside the shard surface at the next commit().
Sourcepub fn remove(&self, node_id: u64) -> Result<bool, String>
pub fn remove(&self, node_id: u64) -> Result<bool, String>
Remove a vector. Returns whether it existed.
Sourcepub fn commit(&self) -> Result<(), String>
pub fn commit(&self) -> Result<(), String>
Persist every shard and the router. Reports the first insert error of each shard since its last commit.
Sourcepub fn search(
&self,
query: &SparseVector,
limit: usize,
) -> Result<Vec<(u64, f32)>, String>
pub fn search( &self, query: &SparseVector, limit: usize, ) -> Result<Vec<(u64, f32)>, String>
Top-limit by dot product across all shards.
Sourcepub fn search_filtered(
&self,
query: &SparseVector,
limit: usize,
allowed_ids: &[u64],
) -> Result<Vec<(u64, f32)>, String>
pub fn search_filtered( &self, query: &SparseVector, limit: usize, allowed_ids: &[u64], ) -> Result<Vec<(u64, f32)>, String>
search restricted to allowed_ids.
Sourcepub fn close(&self) -> Result<(), String>
pub fn close(&self) -> Result<(), String>
Commit, stop the shard actors, make the handle inert.
Sourcepub fn drop_index(self) -> Result<(), String>
pub fn drop_index(self) -> Result<(), String>
Close, then destroy the storage (shards and root files).