Flat Orchestrator
Documentation for the type-erased version of thesvs::index::flat::FlatIndex.
- classFlat:publicsvs::manager::IndexManager<FlatInterface>
Type erased container for theFlat index.
Public Types
- usingsearch_parameters_type=typenameIFace::search_parameters_type
Require the presence of the
search_parameters_typealias in the instantiating interface.
Public Functions
- inlinevoidsave(conststd::filesystem::path&data_directory)const
Save theFlat index to disk.
- Parameters:
data_directory – Directory where the index data will be saved.
- template<typenameQuery>
inlinedoubleget_distance(size_tid,constQuery&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
- inlinesize_tsize()const
Return the number of elements in the indexed dataset.
- inlinesize_tdimensions()const
Return the logical number of dimensions of each vector in the indexed dataset.
- inlinestd::vector<svs::DataType>query_types()const
Return query-types that this index is specialized to work with.
- inlinesize_tget_num_threads()const
Return the current number of worker threads used by this index for searches.
- inlinevoidset_threadpool(Poolthreadpool)
Destroy the original thread pool and set to the new one.
ThreadPool
An acceptable thread pool should implement two methods:
size_tsize(). This method should return the number of threads used in the thread pool.voidparallel_for(std::function<void(size_t)>f,size_tn). This method should executef. Here,f(i)represents a task on thei^thpartition, andnrepresents the number of partitions that need to be executed.
- Parameters:
threadpool – An acceptable thread pool.
- inlinethreads::ThreadPoolHandle&get_threadpool_handle()
Return the current thread pool handle.
Public Static Functions
- template<manager::QueryTypeDefinitionQueryTypes,typenameDataLoader,typenameDistance,typenameThreadPoolProto>
staticinlineFlatassemble(DataLoader&&data_loader,Distancedistance,ThreadPoolProtothreadpool_proto) Load aFlat Index from an existing dataset.
data_loader
The data loader should be any object loadable via
svs::detail::dispatch_loadreturning aVamana compatible dataset. Concrete examples include:An instance of
VectorDataLoader.An implementation of
svs::data::ImmutableMemoryDataset(passed by value).
ThreadPool
An acceptable thread pool should implement two methods:
size_tsize(). This method should return the number of threads used in the thread pool.voidparallel_for(std::function<void(size_t)>f,size_tn). This method should executef. Here,f(i)represents a task on thei^thpartition, andnrepresents 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::DistanceTypeenum.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_protoas the number of threads to create.
- structAssembleTag
Internal dispatch tag.
- usingsearch_parameters_type=typenameIFace::search_parameters_type