pub struct Graph { /* private fields */ }Expand description
A built proximity graph, before any encoding: over normalized vectors (angular) or the vectors as given (Euclidean). Holds a full-precision copy of the data, so it is a build-time object; the indexes keep only their encodings.
Implementations§
Source§impl Graph
Benchmark support: the graph structure (not the vectors) on disk, so that search
experiments on one graph need not rebuild it.
impl Graph
Benchmark support: the graph structure (not the vectors) on disk, so that search experiments on one graph need not rebuild it.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Writes the header (n, dim, degree, build_ef, alpha, seed, entry, data fingerprint, quantized_search, metric), the adjacency and the upper layers; the vectors are not stored.
Sourcepub fn load(
data: &[f32],
dim: usize,
path: &Path,
params: &BuildParams,
) -> Result<Self>
pub fn load( data: &[f32], dim: usize, path: &Path, params: &BuildParams, ) -> Result<Self>
Reads a graph written by Graph::save for the same data (prepared here exactly
as Graph::build does) and the same params. Any mismatch in the vector count,
dimension, degree, build_ef, alpha, seed, quantized search, metric or the data
fingerprint is an error, so a stale cache never stands in for a build; delete the file
to rebuild.
Source§impl Graph
impl Graph
Sourcepub fn structure_hash(&self) -> u64
pub fn structure_hash(&self) -> u64
Stable 64-bit hash of the structure (adjacency, upper layers, entry): equal values mean a bit-identical graph, across builds, binaries and cache round trips.
Sourcepub fn build(
data: &[f32],
dim: usize,
params: &BuildParams,
) -> Result<Self, HmsError>
pub fn build( data: &[f32], dim: usize, params: &BuildParams, ) -> Result<Self, HmsError>
Build over data (row-major, dim floats per vector). Angular rows are normalized;
zero rows stay zero. Uses the rayon pool; the result depends only on the data and
params (code_bits is not used).
Sourcepub fn build_owned(
data: Vec<f32>,
dim: usize,
params: &BuildParams,
) -> Result<Self, HmsError>
pub fn build_owned( data: Vec<f32>, dim: usize, params: &BuildParams, ) -> Result<Self, HmsError>
Graph::build over an owned matrix, prepared in place: the caller’s copy is the
one the graph keeps, so the vectors are resident once during construction instead of
twice (the build’s own copy next to the caller’s).
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.