Skip to main content

BatchIngestPipeline

Struct BatchIngestPipeline 

Source
pub struct BatchIngestPipeline<Id>
where Id: Clone + Eq + Debug,
{ /* private fields */ }
Expand description

High-throughput batch ingest pipeline for encoding and inserting large vector corpora into a FibSidecarIndex.

The pipeline owns a FibQuantizer for encoding and a FibSidecarIndex for storage. Vectors are processed in configurable batch sizes via ingest_batch or ingest_from_iter, with each batch producing an IngestReceipt for progress tracking.

§Parallelism

FibQuantizer::encode_batch uses Rayon parallelism internally when the parallel feature is enabled (default) and the batch is large enough to amortize dispatch overhead (≥ 16 vectors). The pipeline itself does not add additional parallelism — it relies on the codec’s internal parallelism for the compute-heavy encoding step.

§Generics

Id must be Clone + Eq + Debug, matching the bound on FibSidecarIndex. Common choices are u64, String, or a newtype key.

Implementations§

Source§

impl<Id> BatchIngestPipeline<Id>
where Id: Clone + Eq + Debug,

Source

pub fn new(quantizer: FibQuantizer, batch_size: usize) -> Result<Self>

Create a new batch ingest pipeline.

Builds a FibScorer from the quantizer (cloning it so the pipeline retains its own copy for encoding) and creates an empty FibSidecarIndex.

batch_size is the default chunk size used by ingest_from_iter. It must be > 0.

§Errors

Returns FibQuantError::CorruptPayload if batch_size is 0.

Source

pub fn ingest_batch(&mut self, items: &[(Id, &[f32])]) -> Result<IngestReceipt>

Ingest a batch of (Id, vector) pairs.

Extracts all f32 vector slices, calls FibQuantizer::encode_batch for parallel encoding (Rayon when the parallel feature is enabled and the batch is ≥ 16 vectors), then adds all encoded codes to the sidecar index via FibSidecarIndex::add_batch. Returns an IngestReceipt with the count, bytes, timing, and any errors.

If encoding fails for the entire batch (e.g., dimension mismatch or a zero-norm vector), the receipt will have failed = items.len() and the error will be recorded in error_messages. The index is not modified in this case.

§Empty batches

An empty items slice returns a zero-count receipt immediately without touching the quantizer or index.

Source

pub fn ingest_from_iter<I>(&mut self, iter: I) -> Result<Vec<IngestReceipt>>
where I: Iterator<Item = (Id, Vec<f32>)>,

Ingest vectors from an iterator, chunking into batch_size pieces.

Each chunk is passed to ingest_batch, and all receipts are collected and returned. This is the primary entry point for streaming large corpora (100K+ vectors) through the pipeline.

The iterator is consumed lazily — only one chunk is held in memory at a time (plus the receipts vector). This keeps memory usage bounded regardless of the total corpus size.

Source

pub fn finish(self) -> FibSidecarIndex<Id>

Consume the pipeline and return the completed FibSidecarIndex.

The index contains all successfully encoded and inserted entries. After calling finish, the pipeline is consumed and can no longer be used.

Source

pub fn total_encoded(&self) -> usize

Number of vectors successfully encoded and inserted so far.

Source

pub fn total_bytes(&self) -> u64

Total encoded bytes accumulated so far.

Source

pub fn failed(&self) -> usize

Number of vectors that failed to encode or insert so far.

Source

pub fn batch_size(&self) -> usize

Configured batch size.

Source

pub fn len(&self) -> usize

Current number of entries in the underlying index.

Source

pub fn is_empty(&self) -> bool

Whether the index is empty.

Auto Trait Implementations§

§

impl<Id> Freeze for BatchIngestPipeline<Id>

§

impl<Id> RefUnwindSafe for BatchIngestPipeline<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for BatchIngestPipeline<Id>
where Id: Send,

§

impl<Id> Sync for BatchIngestPipeline<Id>
where Id: Sync,

§

impl<Id> Unpin for BatchIngestPipeline<Id>
where Id: Unpin,

§

impl<Id> UnsafeUnpin for BatchIngestPipeline<Id>

§

impl<Id> UnwindSafe for BatchIngestPipeline<Id>
where Id: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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