pub struct FlatVectorData;Expand description
Flat vector binary format helpers for writing.
Binary format v3:
[magic(u32)][dim(u32)][num_vectors(u32)][quant_type(u8)][padding(3)]
[vectors: N×dim×element_size]
[doc_ids: N×(u32+u16)]element_size is determined by quant_type: f32=4, f16=2, uint8=1.
Packed binary vectors instead use dim / 8 bytes per row.
LazyFlatVectorData retains a zero-copy view of the packed document/ordinal
map and accesses vector payloads lazily via range reads (mmap on native files).
Implementations§
Source§impl FlatVectorData
impl FlatVectorData
Sourcepub fn write_binary_header(
dim: usize,
num_vectors: usize,
quant: DenseVectorQuantization,
writer: &mut dyn Write,
) -> Result<()>
pub fn write_binary_header( dim: usize, num_vectors: usize, quant: DenseVectorQuantization, writer: &mut dyn Write, ) -> Result<()>
Write the binary header to a writer.
Sourcepub fn serialized_binary_size(
dim: usize,
num_vectors: usize,
quant: DenseVectorQuantization,
) -> Result<usize>
pub fn serialized_binary_size( dim: usize, num_vectors: usize, quant: DenseVectorQuantization, ) -> Result<usize>
Compute the serialized size without actually serializing.
Sourcepub fn serialize_binary_from_flat_streaming(
dim: usize,
flat_vectors: &[f32],
doc_ids: &[(u32, u16)],
quant: DenseVectorQuantization,
writer: &mut dyn Write,
) -> Result<()>
pub fn serialize_binary_from_flat_streaming( dim: usize, flat_vectors: &[f32], doc_ids: &[(u32, u16)], quant: DenseVectorQuantization, writer: &mut dyn Write, ) -> Result<()>
Stream from flat f32 storage to a writer, quantizing on write.
flat_vectors is contiguous storage of dim*n f32 floats.
Vectors are quantized to the specified format before writing.
Sourcepub fn serialize_binary_from_bits_streaming(
dim_bits: usize,
packed_vectors: &[u8],
doc_ids: &[(u32, u16)],
writer: &mut dyn Write,
) -> Result<()>
pub fn serialize_binary_from_bits_streaming( dim_bits: usize, packed_vectors: &[u8], doc_ids: &[(u32, u16)], writer: &mut dyn Write, ) -> Result<()>
Stream packed binary vectors (pre-packed bytes) to a writer.
packed_vectors is contiguous storage of num_vectors * byte_len bytes.
dim_bits is the number of bits (dimensions).
Auto Trait Implementations§
impl Freeze for FlatVectorData
impl RefUnwindSafe for FlatVectorData
impl Send for FlatVectorData
impl Sync for FlatVectorData
impl Unpin for FlatVectorData
impl UnsafeUnpin for FlatVectorData
impl UnwindSafe for FlatVectorData
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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