Flat Orchestrator
Documentation for the type-erased version of the svs::index::flat::FlatIndex
.
-
class Flat : public svs::manager::IndexManager<FlatInterface>
Type erased container for the Flat index.
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 void save(const std::filesystem::path &data_directory) const
Save the Flat index to disk.
- Parameters:
data_directory – Directory where the index data will be saved.
-
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 executef
. Here,f(i)
represents a task on thei^th
partition, andn
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 Flat assemble(DataLoader &&data_loader, Distance distance, ThreadPoolProto threadpool_proto) Load a Flat Index from an existing dataset.
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 executef
. Here,f(i)
represents a task on thei^th
partition, andn
represents the number of partitions that need to be executed.
- Template Parameters:
QueryType – The element type of the vectors that will be used for querying.
- Parameters:
data_loader – A compatible class capable of load data. See expanded notes.
distance – A distance functor to use or a
svs::DistanceType
enum.threadpool_proto – Precursor for the thread pool to use. Can either be an acceptable thread pool instance or an integer specifying the number of threads to use. In the latter case, a new default thread pool will be constructed using
threadpool_proto
as the number of threads to create.
-
struct AssembleTag
Internal dispatch tag.
-
using search_parameters_type = typename IFace::search_parameters_type