Struct usearch::ffi::Index

source ·
#[repr(C)]
pub struct Index { /* private fields */ }
Expand description

Represents the USearch index.

Implementations§

source§

impl Index

source

pub fn reserve(&self, capacity: usize) -> Result<(), Exception>

Reserves memory for a specified number of incoming vectors.

Arguments
  • capacity - The desired total capacity including the current size.
source§

impl Index

source

pub fn dimensions(&self) -> usize

Retrieves the number of dimensions in the vectors indexed.

source§

impl Index

source

pub fn connectivity(&self) -> usize

Retrieves the connectivity parameter that limits connections-per-node in the graph.

source§

impl Index

source

pub fn size(&self) -> usize

Retrieves the current number of vectors in the index.

source§

impl Index

source

pub fn capacity(&self) -> usize

Retrieves the total capacity of the index, including reserved space.

source§

impl Index

source

pub fn serialized_length(&self) -> usize

Reports expected file size after serialization.

source§

impl Index

source

pub fn add(&self, key: u64, vector: &[f32]) -> Result<(), Exception>

Adds a vector with a specified key to the index.

Arguments
  • key - The key associated with the vector.
  • vector - A slice containing the vector data.
source§

impl Index

source

pub fn add_i8(&self, key: u64, vector: &[i8]) -> Result<(), Exception>

source§

impl Index

source

pub fn add_f16(&self, key: u64, vector: &[u16]) -> Result<(), Exception>

source§

impl Index

source

pub fn add_f32(&self, key: u64, vector: &[f32]) -> Result<(), Exception>

source§

impl Index

source

pub fn add_f64(&self, key: u64, vector: &[f64]) -> Result<(), Exception>

source§

impl Index

source

pub fn search(&self, query: &[f32], count: usize) -> Result<Matches, Exception>

Performs k-Approximate Nearest Neighbors (kANN) Search for closest vectors to the provided query.

Arguments
  • query - A slice containing the query vector data.
  • count - The maximum number of neighbors to search for.
Returns

A Result containing the matches found.

source§

impl Index

source

pub fn search_i8( &self, query: &[i8], count: usize ) -> Result<Matches, Exception>

source§

impl Index

source

pub fn search_f16( &self, query: &[u16], count: usize ) -> Result<Matches, Exception>

source§

impl Index

source

pub fn search_f32( &self, query: &[f32], count: usize ) -> Result<Matches, Exception>

source§

impl Index

source

pub fn search_f64( &self, query: &[f64], count: usize ) -> Result<Matches, Exception>

source§

impl Index

source

pub fn remove(&self, key: u64) -> Result<bool, Exception>

Removes the vector associated with the given key from the index.

Arguments
  • key - The key of the vector to be removed.
Returns

true if the vector is successfully removed, false otherwise.

source§

impl Index

source

pub fn rename(&self, from: u64, to: u64) -> Result<bool, Exception>

Renames the vector under a certain key.

Arguments
  • from - The key of the vector to be renamed.
  • to - The new name.
Returns

true if the vector is successfully renamed, false otherwise.

source§

impl Index

source

pub fn contains(&self, key: u64) -> bool

Checks if the index contains a vector with a specified key.

Arguments
  • key - The key to be checked.
Returns

true if the index contains the vector with the given key, false otherwise.

source§

impl Index

source

pub fn save(&self, path: &str) -> Result<(), Exception>

Saves the index to a specified file.

Arguments
  • path - The file path where the index will be saved.
source§

impl Index

source

pub fn load(&self, path: &str) -> Result<(), Exception>

Loads the index from a specified file.

Arguments
  • path - The file path from where the index will be loaded.
source§

impl Index

source

pub fn view(&self, path: &str) -> Result<(), Exception>

Creates a view of the index from a file without loading it into memory.

Arguments
  • path - The file path from where the view will be created.
source§

impl Index

source

pub fn save_to_buffer(&self, buffer: &mut [u8]) -> Result<(), Exception>

Saves the index to a specified file.

Arguments
  • path - The file path where the index will be saved.
source§

impl Index

source

pub fn load_from_buffer(&self, buffer: &[u8]) -> Result<(), Exception>

Loads the index from a specified file.

Arguments
  • path - The file path from where the index will be loaded.
source§

impl Index

source

pub fn view_from_buffer(&self, buffer: &[u8]) -> Result<(), Exception>

Creates a view of the index from a file without loading it into memory.

Arguments
  • path - The file path from where the view will be created.

Trait Implementations§

source§

impl ExternType for Index

§

type Kind = Opaque

§

type Id

A type-level representation of the type’s C++ namespace and type name. Read more
source§

impl UniquePtrTarget for Index

Auto Trait Implementations§

§

impl RefUnwindSafe for Index

§

impl !Send for Index

§

impl !Sync for Index

§

impl !Unpin for Index

§

impl UnwindSafe for Index

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.