Skip to main content

MultiLayerNodeManager

Struct MultiLayerNodeManager 

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

Multi-layer node manager that orchestrates layer operations

Provides high-level interface for multi-layer HNSW functionality, coordinating between vector storage, layer management, and search operations. Wraps existing single-layer components to provide multi-layer capabilities.

§Key Responsibilities

  • Coordinate insertions across multiple layers
  • Manage bidirectional ID mappings
  • Orchestrate multi-layer search operations
  • Provide feature flag for safe migration

Implementations§

Source§

impl MultiLayerNodeManager

Source

pub fn new(config: HnswConfig) -> Result<Self, HnswError>

Create new multi-layer node manager

§Arguments
  • config - HNSW configuration
§Returns

New MultiLayerNodeManager instance

Source

pub fn insert_vector( &mut self, vector_id: u64, ) -> Result<(usize, Vec<(usize, u64)>), HnswError>

Insert vector into appropriate layers

§Arguments
  • vector_id - Global vector ID from storage
§Returns

Tuple of (highest_level, layer_assignments) where layer_assignments is a vector of (layer_id, local_id) pairs

Source

pub fn remove_vector(&mut self, vector_id: u64) -> Result<(), HnswError>

Remove vector from all layers

§Arguments
  • vector_id - Global vector ID to remove
Source

pub fn get_local_id(&self, vector_id: u64, layer_id: usize) -> Option<u64>

Get local ID for global ID in specific layer

§Arguments
  • vector_id - Global vector ID
  • layer_id - Layer ID
§Returns

Local node ID if mapping exists

Source

pub fn get_global_id(&self, layer_id: usize, local_id: u64) -> Option<u64>

Get global ID for local ID in specific layer

§Arguments
  • layer_id - Layer ID
  • local_id - Local node ID
§Returns

Global vector ID if mapping exists

Source

pub fn get_layer_vectors(&self, layer_id: usize) -> Vec<u64>

Get vectors assigned to specific layer

§Arguments
  • layer_id - Layer ID
§Returns

Iterator over global IDs in the layer

Source

pub fn get_vector_level(&self, vector_id: u64) -> Option<usize>

Get highest level assignment for a vector

§Arguments
  • vector_id - Global vector ID
§Returns

Highest layer where vector exists, or None if not inserted

Source

pub fn get_statistics(&self) -> (usize, Vec<usize>, usize)

Get statistics about layer distribution

§Returns

Tuple of (total_vectors, layer_counts, memory_usage)

Source

pub fn validate_consistency(&self) -> Result<(), HnswError>

Validate all mappings and consistency

§Returns

Ok(()) if all mappings are consistent

Source

pub fn clear(&mut self) -> Result<(), HnswError>

Clear all mappings and start fresh

Trait Implementations§

Source§

impl Debug for MultiLayerNodeManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V