Enum abd_clam::Cakes

source ·
pub enum Cakes<I: Instance, U: Number, D: Dataset<I, U>> {
    SingleShard(SingleShard<I, U, D>),
    RandomlySharded(RandomlySharded<I, U, D>),
}
Expand description

CAKES search.

Variants§

§

SingleShard(SingleShard<I, U, D>)

Search with a single shard.

§

RandomlySharded(RandomlySharded<I, U, D>)

Search with multiple shards.

Implementations§

source§

impl<I: Instance, U: Number, D: Dataset<I, U>> Cakes<I, U, D>

source

pub fn new<P: PartitionCriterion<U>>( data: D, seed: Option<u64>, criteria: &P ) -> Self

Creates a new CAKES instance with a single shard dataset.

§Arguments
  • data - The dataset to search.
  • seed - The seed to use for the random number generator.
  • criteria - The criteria to use for partitioning the tree.
source

pub fn save(&self, path: &Path) -> Result<(), String>

Saves the Cakes structure to the given path.

§Arguments
  • path - The path to save the Cakes structure to.
§Errors
  • If the path does not exist.
  • If the path is not a valid directory.
source

pub fn load( path: &Path, metric: fn(_: &I, _: &I) -> U, is_expensive: bool ) -> Result<Self, String>

Loads the Cakes structure from the given path.

§Arguments
  • path - The path to load the Cakes structure from.
  • metric - The metric to use for the search.
  • is_expensive - Whether the metric is expensive to compute.
§Returns

The Cakes structure.

§Errors
  • If the path does not exist.
  • If the path is not a valid directory.
  • If the path does not contain a valid Cakes structure.
source

pub fn trees(&self) -> Vec<&Tree<I, U, D, UniBall<U>>>

Returns the references to the tree(s) of the dataset.

source

pub fn shards(&self) -> Vec<&D>

Returns the references to the shard(s) of the dataset.

source

pub fn new_randomly_sharded<P: PartitionCriterion<U>>( shards: Vec<D>, seed: Option<u64>, criteria: &P ) -> Self

Creates a new CAKES instance with a randomly sharded dataset.

§Arguments
  • shards - The shards of the dataset to search.
  • seed - The seed to use for the random number generator.
  • criteria - The criteria to use for partitioning the tree.
source

pub fn num_shards(&self) -> usize

Returns the number of shards in the dataset.

source

pub fn shard_cardinalities(&self) -> Vec<usize>

Returns the cardinalities of the shards in the dataset.

source

pub fn total_cardinality(&self) -> usize

Returns the total cardinality of the dataset.

source

pub fn tuned_rnn_algorithm(&self) -> Algorithm

Returns the tuned RNN algorithm.

Performs RNN search on a batch of queries with the given algorithm.

§Arguments
  • queries - The queries to search.
  • radius - The search radius.
  • algo - The algorithm to use.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs an RNN search with the given algorithm.

§Arguments
  • query - The query instance.
  • radius - The search radius.
  • algo - The algorithm to use.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

Performs Linear RNN search on a batch of queries.

§Arguments
  • queries - The queries to search.
  • radius - The search radius.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs a linear RNN search.

§Arguments
  • query - The query instance.
  • radius - The search radius.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

source

pub fn tuned_knn_algorithm(&self) -> Algorithm

Returns the tuned KNN algorithm.

Performs KNN search on a batch of queries with the given algorithm.

§Arguments
  • queries - The queries to search.
  • k - The number of nearest neighbors to return.
  • algo - The algorithm to use.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs a KNN search with the given algorithm.

§Arguments
  • query - The query instance.
  • k - The number of nearest neighbors to return.
  • algo - The algorithm to use.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

source

pub fn auto_tune_rnn(&mut self, radius: U, tuning_depth: usize)

Automatically finds the best RNN algorithm to use.

§Arguments
  • radius - The search radius.
  • tuning_depth - The number of instances to use for tuning.
source

pub fn auto_tune_knn(&mut self, k: usize, tuning_depth: usize)

Automatically finds the best KNN algorithm to use.

§Arguments
  • k - The number of nearest neighbors to return.
  • tuning_depth - The number of instances to use for tuning.

Performs Linear KNN search on a batch of queries.

§Arguments
  • queries - The queries to search.
  • k - The number of nearest neighbors to return.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs a linear KNN search.

§Arguments
  • query - The query instance.
  • k - The number of nearest neighbors to return.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

Performs RNN search on a batch of queries with the tuned algorithm.

If the algorithm has not been tuned, this will use the default algorithm.

§Arguments
  • queries - The queries to search.
  • radius - The search radius.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs a RNN search with the tuned algorithm.

If the algorithm has not been tuned, this will use the default algorithm.

§Arguments
  • query - The query instance.
  • radius - The search radius.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

Performs KNN search on a batch of queries with the tuned algorithm.

If the algorithm has not been tuned, this will use the default algorithm.

§Arguments
  • queries - The queries to search.
  • k - The number of nearest neighbors to return.
§Returns

A vector of vectors of tuples containing the index of the instance and the distance to the query.

Performs a KNN search with the tuned algorithm.

If the algorithm has not been tuned, this will use the default algorithm.

§Arguments
  • query - The query instance.
  • k - The number of nearest neighbors to return.
§Returns

A vector of tuples containing the index of the instance and the distance to the query.

Trait Implementations§

source§

impl<I, U, D> Index<usize> for Cakes<I, U, D>
where I: Instance, U: Number, D: Dataset<I, U>,

§

type Output = I

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<I, U, D> RefUnwindSafe for Cakes<I, U, D>

§

impl<I, U, D> Send for Cakes<I, U, D>

§

impl<I, U, D> Sync for Cakes<I, U, D>

§

impl<I, U, D> Unpin for Cakes<I, U, D>
where D: Unpin, I: Unpin, U: Unpin,

§

impl<I, U, D> UnwindSafe for Cakes<I, U, D>
where D: UnwindSafe, I: UnwindSafe, U: UnwindSafe,

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

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>,

§

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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V