Skip to main content

VectorIndex

Struct VectorIndex 

Source
pub struct VectorIndex<'s> { /* private fields */ }
Expand description

The vectors of one model across a family’s segments.

Built once per segment set; every search and every checkout reading the same segments shares it, and its segments read through the shared block cache.

Implementations§

Source§

impl<'s> VectorIndex<'s>

Source

pub fn build( segments: impl IntoIterator<Item = VectorSegment<'s>>, model: &ModelIdentity, ) -> Result<Self, VectorError>

The vectors of model in segments, which are in the order a snapshot lists them: by ascending id, so newer segments come later. Segments of other models are left out.

§Errors

When a segment cannot be read.

Source

pub fn model(&self) -> &ModelIdentity

Source

pub fn vectors(&self) -> usize

How many distinct vectors of the model the segments hold. Zero means no vectors for this model at all, which a search reports as VectorError::NoVectors rather than as an empty answer.

Source

pub fn segments(&self) -> &[VectorSegment<'s>]

Source

pub fn locate(&self, text: TextDigest) -> Option<UnitRef>

Where the vector embedded for text is.

Source

pub fn vector(&self, unit: UnitRef) -> Result<Vec<f32>, VectorError>

The stored f32 vector at unit.

§Errors

When unit is not in the index, or a read fails.

Source

pub fn chunk_map( &self, content: ContentKey, path: &[u8], ) -> Result<Option<Vec<MappedChunk>>, VectorError>

The chunks of the file at path with content, in chunk order, each with its vector if one is stored. None when no segment has a chunk map for the file: its chunks were never embedded under this model.

§Errors

When a read fails or a map is malformed.

Source

pub fn chunk_details( &self, content: ContentKey, path: &[u8], ) -> Result<Option<FileDetails>, VectorError>

The details recorded with the chunk map chunk_map returns for the same file: None when no segment has a map for it, or its map was stored without details.

§Errors

When a read fails or the details are malformed.

Source

pub fn file_members<'p>( &self, files: impl IntoIterator<Item = (ContentKey, &'p [u8])>, ) -> Result<FileMembers, VectorError>

The members of a set of files, in the order given and then in chunk order, with how much of them has vectors.

§Errors

When a read fails or a map is malformed.

Source

pub fn member_set(&self, members: Vec<Member>) -> Result<MemberSet, VectorError>

Prepares members for searching. Their order is the tie-break: among equal scores, the member listed first ranks first, as the entry enumerated first does in today’s index.

§Errors

When a member names a vector the index does not have.

Source

pub fn search( &self, members: &MemberSet, request: &SearchRequest<'_>, ) -> Result<SearchResult, VectorError>

The exact top k members for request: today’s f32 scores, in today’s order, ties broken by member position.

§Errors

VectorError::NoVectors when the segments hold no vector of this model; VectorError::DimensionMismatch or VectorError::NonFinite for a query the model cannot score; VectorError::ForeignMembers for a member set prepared by another index; otherwise when a read fails or a block fails its checksum.

Source

pub fn bounds( &self, members: &MemberSet, query: &[f32], ) -> Result<Vec<ScoreBounds>, VectorError>

The interval each member’s exact score is proven to lie in, from the int8 scan alone, in member order. A search excludes members by these same bounds; gates use this to check that the bounds hold.

§Errors

As search.

Trait Implementations§

Source§

impl<'s> Debug for VectorIndex<'s>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'s> Forget for VectorIndex<'s>

§

impl<'s> Freeze for VectorIndex<'s>

§

impl<'s> Move for VectorIndex<'s>

§

impl<'s> RefUnwindSafe for VectorIndex<'s>

§

impl<'s> Send for VectorIndex<'s>

§

impl<'s> Sync for VectorIndex<'s>

§

impl<'s> Unpin for VectorIndex<'s>

§

impl<'s> UnsafeUnpin for VectorIndex<'s>

§

impl<'s> UnwindSafe for VectorIndex<'s>

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.