Skip to main content

StreamBuffer

Struct StreamBuffer 

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

A buffer for streaming vector updates.

§Design

The buffer maintains:

  1. Insert buffer: New vectors not yet in main index
  2. Delete set: IDs marked for deletion (applied during compaction)

During search, both buffer and main index are queried, with delete set filtering applied to results.

Implementations§

Source§

impl StreamBuffer

Source

pub fn new() -> Self

Source

pub fn with_config(config: StreamBufferConfig) -> Self

Source

pub fn insert(&mut self, id: u32, vector: Vec<f32>) -> Result<()>

Insert a vector into the buffer.

Source

pub fn delete(&mut self, id: u32)

Mark an ID for deletion.

Source

pub fn needs_compaction(&self) -> bool

Check if buffer needs compaction.

Source

pub fn drain(&mut self) -> (HashMap<u32, Vec<f32>>, HashSet<u32>)

Drain the buffer for compaction.

Source

pub fn insert_count(&self) -> usize

Number of buffered inserts.

Source

pub fn delete_count(&self) -> usize

Number of pending deletes.

Source

pub fn is_deleted(&self, id: u32) -> bool

Check if an ID is pending delete.

Source

pub fn get(&self, id: u32) -> Option<&Vec<f32>>

Get a vector from the buffer (if present).

Source

pub fn iter(&self) -> impl Iterator<Item = (u32, &Vec<f32>)>

Iterate over buffered vectors.

Source

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

Brute-force search in buffer.

Returns (id, distance) pairs sorted by distance ascending.

Trait Implementations§

Source§

impl Debug for StreamBuffer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for StreamBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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