Skip to main content

ImageHeader

Struct ImageHeader 

Source
pub struct ImageHeader {
Show 18 fields pub kind: u8, pub bits: u8, pub metric: u8, pub dim: u32, pub partitions: u32, pub seed: u64, pub members: u64, pub slots: u32, pub posting: u32, pub probe: u32, pub rerank: u32, pub sweep: u32, pub widen: u32, pub spill: u32, pub slack: f32, pub patience: u32, pub centroids: Chain, pub keys: Chain,
}
Expand description

The root of an image: everything the index is, apart from the members.

The two chains here and the partition table after it are addresses into the log, so this is small whatever the collection’s size: a few dozen bytes plus sixteen per partition.

Fields§

§kind: u8

Which index this is an image of. See image_kind.

§bits: u8

How wide one coordinate is written in a code, which is 1 or 4.

§metric: u8

What nearness means here. See metric.

§dim: u32

How many coordinates a vector has.

§partitions: u32

How many partitions the index has grown to.

§seed: u64

What the rotation was built from. Without it the codes are noise.

§members: u64

How many vectors the collection held, for a check after loading.

§slots: u32

How many slots the vector table had, which is the largest id plus one.

An id is a slot rather than a name, and a collection that has had members removed has holes in it, so the count of live members does not say how far the ids go. Writing it down means a loader allocates the table once and can refuse an id that is past the end of it before it is used to index anything.

§posting: u32

The size a partition wants.

§probe: u32

How many partitions a search scans.

§rerank: u32

How many candidates are reranked per answer.

§sweep: u32

How many neighbours a split sweeps.

§widen: u32

How much further a filtered search looks.

§spill: u32

How many partitions one vector may be written into.

Part of the image rather than left to whatever the loader happens to be tuned to, because it says how the collection was built. A collection built with boundary copies and reopened without them keeps the copies it has and stops making new ones, which is a recall curve that changes under the caller for a reason nothing reports.

§slack: f32

How much further than the nearest centroid a copy is still made, as a fraction.

§patience: u32

How many partitions in a row may add nothing before a search stops.

§centroids: Chain

Where the centroids are, and how many bytes of them there are.

§keys: Chain

Where the key table is, and how long it is.

Implementations§

Source§

impl ImageHeader

Source

pub fn encode(&self, into: &mut [u8]) -> Result<usize>

Writes the header into the first IMAGE_HEADER_LEN bytes of into.

§Errors

Code::Invalid if into is shorter than a whole root, header and partition table both, because a header written into a buffer that cannot hold the table it describes is a root nobody can read.

Source

pub fn decode(bytes: &[u8]) -> Result<ImageHeader>

Reads a header back and checks that the bytes behind it are a whole partition table.

§Errors

Code::Corrupt if the tag is wrong, if a reserved field is set, if the dimension or the code width is not one this version writes, or if the buffer is not as long as the partition count says it is.

Trait Implementations§

Source§

impl Clone for ImageHeader

Source§

fn clone(&self) -> ImageHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ImageHeader

Source§

impl Debug for ImageHeader

Source§

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

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

impl Default for ImageHeader

Source§

fn default() -> ImageHeader

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ImageHeader

Source§

fn eq(&self, other: &ImageHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ImageHeader

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.