MetricKnn API
Fast Similarity Search using the Metric Space Approach
|
A Index represents the index structure. More...
#include <mknn_index.hpp>
Public Member Functions | |
IndexParams & | getParameters () |
Returns the parameters used to create or load the index. More... | |
Dataset & | getSearchDataset () |
Returns the dataset used to create or load the index. More... | |
Distance & | getDistance () |
Returns the distance used to create or load the index. More... | |
std::string | getIdPredefinedIndex () |
returns the id of the predefined index. More... | |
void | save (std::string filename_write) |
Saves the built index to a file. More... | |
Resolver | newResolver (ResolverParams ¶meters_resolver) |
Configures a new similarity search using the given index. More... | |
Index () | |
Default constructor. | |
virtual | ~Index () |
Default destructor. | |
Index (const Index &other) | |
Copy constructor. | |
Index & | operator= (const Index &other) |
Assignment operator. | |
Static Public Member Functions | |
static Index | newPredefined (IndexParams ¶meters, Dataset &search_dataset, Distance &distance) |
Instantiates a new index identified by the given parameters. More... | |
static Index | restore (std::string filename_read, Dataset &search_dataset, Distance &distance, IndexParams &more_parameters) |
Loads an index from a file. More... | |
Protected Attributes | |
std::unique_ptr< Impl > | pimpl |
opaque object | |
A Index represents the index structure.
In order to create an index, at least two parameters must be provided:
MetricKnn provides a set of pre-defined indexes identified by a unique distance identifier. Some valid IDs are:
LINEARSCAN
The naive sequential scan of the search dataset. LAESA
The LAESA metric access method. http://dx.doi.org/10.1016/0167-8655(94)90095-7 FLANN-KDTREE
The kd-tree, implemented by FLANN library. FLANN-KMEANS
The k-means tree, implemented by FLANN library.The multidimensional indexes are implemented by the FLANN library. http://www.cs.ubc.ca/research/flann/
In order to simplify the creation of distances, there are defined constructors for the different distances which internally invoke Index::newPredefined.
Distance& mknn::Index::getDistance | ( | ) |
Returns the distance used to create or load the index.
std::string mknn::Index::getIdPredefinedIndex | ( | ) |
returns the id of the predefined index.
IndexParams& mknn::Index::getParameters | ( | ) |
Returns the parameters used to create or load the index.
Dataset& mknn::Index::getSearchDataset | ( | ) |
Returns the dataset used to create or load the index.
|
static |
Instantiates a new index identified by the given parameters.
parameters | the definition of the index. |
delete_parameters_on_index_release | binds the lifetime of parameters to the new index. |
search_dataset | the data to be indexed. Any search on this index will return some object from search_data . |
delete_search_dataset_on_index_release | binds the lifetime of search_dataset to the new index. |
distance | a distance. |
delete_distance_on_index_release | binds the lifetime of distance to the new index. |
Resolver mknn::Index::newResolver | ( | ResolverParams & | parameters_resolver | ) |
Configures a new similarity search using the given index.
parameters_resolver | parameters to be given to the index in order to resolve the search. |
delete_parameters_on_resolver_release | binds the lifetime of parameters_resolver to the new resolver. |
|
static |
Loads an index from a file.
The file must have been created by save.
search_dataset
and dist_factory
must be the same that were used to create and save the index.filename_read | File to read. If the file does not exists an error is raised. |
search_dataset | The search dataset that was used to build the index. |
delete_search_dataset_on_index_release | binds the lifetime of search_dataset to the new index. |
distance | The distance that was used to build the index. |
delete_distance_on_index_release | binds the lifetime of distance to the new index. |
more_parameters | any parameter that may override the stored parameters or new parameters that could not be saved. |
delete_parameters_on_index_release | binds the lifetime of more_parameters to the new index. |
void mknn::Index::save | ( | std::string | filename_write | ) |
Saves the built index to a file.
It may create other files using filename_write
as prefix. The created files may be in binary format for fast loading.
filename_write | File to create. If the file already exists it is overwritten. |