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>
impl<'s> VectorIndex<'s>
Sourcepub fn build(
segments: impl IntoIterator<Item = VectorSegment<'s>>,
model: &ModelIdentity,
) -> Result<Self, VectorError>
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.
pub fn model(&self) -> &ModelIdentity
Sourcepub fn vectors(&self) -> usize
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.
pub fn segments(&self) -> &[VectorSegment<'s>]
Sourcepub fn locate(&self, text: TextDigest) -> Option<UnitRef>
pub fn locate(&self, text: TextDigest) -> Option<UnitRef>
Where the vector embedded for text is.
Sourcepub fn chunk_map(
&self,
content: ContentKey,
path: &[u8],
) -> Result<Option<Vec<MappedChunk>>, VectorError>
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.
Sourcepub fn chunk_details(
&self,
content: ContentKey,
path: &[u8],
) -> Result<Option<FileDetails>, VectorError>
pub fn chunk_details( &self, content: ContentKey, path: &[u8], ) -> Result<Option<FileDetails>, VectorError>
Sourcepub fn file_members<'p>(
&self,
files: impl IntoIterator<Item = (ContentKey, &'p [u8])>,
) -> Result<FileMembers, VectorError>
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.
Sourcepub fn member_set(&self, members: Vec<Member>) -> Result<MemberSet, VectorError>
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.
Sourcepub fn search(
&self,
members: &MemberSet,
request: &SearchRequest<'_>,
) -> Result<SearchResult, VectorError>
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.