Dynamic Vamana Index

Documentation for the type-erased version of the svs::index::vamana::MutableVamanaIndex.

class DynamicVamana : public svs::manager::IndexManager<DynamicVamanaInterface>

DynamicVamana

Public Types

using search_parameters_type = typename IFace::search_parameters_type

Require the presence of the search_parameters_type alias in the instantiating interface.

Public Functions

inline explicit DynamicVamana(std::unique_ptr<manager::ManagerInterface<DynamicVamanaInterface>> impl)

Construct a new DynamicVamana instance.

Parameters:

impl – A pointer to a concrete implementation of the full DynamicVamanaInteface.

inline DynamicVamana &set_search_window_size(size_t search_window_size)

Set the search window size used to process queries.

Parameters:

search_window_size – The new search window size.

inline size_t get_search_window_size() const

The current search window size used to process queries.

inline float get_alpha() const

Get the alpha value used for pruning while mutating the graph.

inline size_t get_graph_max_degree() const

Get the graph_max_degree used while mutating the graph.

inline size_t get_construction_window_size() const

Set the window size to be used while mutating the graph.

inline size_t get_max_candidates() const

Get the max candidate pool size used while mutating the graph.

inline size_t get_prune_to() const

Get the prune_to value used while mutating the graph.

inline bool get_full_search_history() const

Return whether the full search history is being used while mutating the graph.

inline bool has_id(size_t id) const

Return whether id is in the index.

inline std::vector<size_t> all_ids() const

Return all ids currently in the index.

Note: If the stored index is large, the returned container may result in a significant memory allocation.

If more precise handling is required, please work with the lower level C++ class directly.

inline void reconstruct_at(data::SimpleDataView<float> data, std::span<const uint64_t> ids)

Reconstruction.

template<typename QueryType, size_t N>
inline svs::VamanaIterator batch_iterator(std::span<const QueryType, N> query, size_t extra_search_buffer_capacity = svs::UNSIGNED_INTEGER_PLACEHOLDER) const

Return a new iterator (an instance of svs::VamanaIterator) for the query.

The returned iterator will maintain an internal copy of the query.

Template Parameters:
  • QueryType – The element type of the query that will be given to the iterator.

  • N – The dimension of the query.

Parameters:
  • query – The query to use for the iterator.

  • extra_search_buffer_capacity – An optional extra search buffer capacity to allow the iterator to search beyond the current batch (when not provided, svs::ITERATOR_EXTRA_BUFFER_CAPACITY_DEFAULT = 100 is used).

template<typename Query>
inline double get_distance(size_t id, const Query &query) const

Get the distance between a vector in the index and a query vector.

Distance

Template Parameters:

Query – The query vector type

Parameters:
  • id – The ID of the vector in the index

  • query – The query vector

inline size_t size() const

Return the number of elements in the indexed dataset.

inline size_t dimensions() const

Return the logical number of dimensions of each vector in the indexed dataset.

inline std::vector<svs::DataType> query_types() const

Return query-types that this index is specialized to work with.

inline size_t get_num_threads() const

Return the current number of worker threads used by this index for searches.

inline void set_threadpool(Pool threadpool)

Destroy the original thread pool and set to the new one.

ThreadPool

An acceptable thread pool should implement two methods:

  • size_t size(). This method should return the number of threads used in the thread pool.

  • void parallel_for(std::function<void(size_t)> f, size_t n). This method should execute f. Here, f(i) represents a task on the i^th partition, and n represents the number of partitions that need to be executed.

Parameters:

threadpool – An acceptable thread pool.

inline threads::ThreadPoolHandle &get_threadpool_handle()

Return the current thread pool handle.

Public Static Functions

template<manager::QueryTypeDefinition QueryTypes, typename DataLoader, typename Distance, typename ThreadPoolProto>
static inline DynamicVamana build(const index::vamana::VamanaBuildParameters &parameters, DataLoader &&data_loader, std::span<const size_t> ids, Distance distance, ThreadPoolProto threadpool_proto)

Construct a DynamicVamana index from a data loader or dataset.

Template Parameters:
  • QueryTypes – The set of query element types supported by the resulting index.

  • DataLoader – A data loader or dataset type.

  • Distance – Distance functor or svs::DistanceType enum.

  • ThreadPoolProto – Thread pool type or size_t).

Parameters:
  • parameters – Build parameters controlling graph construction.

  • data_loader – Loader (or dataset) from which to obtain the data.

  • ids – External IDs to assign to each row; must be unique and have length data.size().

  • distance – Distance functor or enum.

  • threadpool_proto – Thread pool or number of threads to use.

struct AssembleTag