MetricKnn API
Fast Similarity Search using the Metric Space Approach
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
mknn::Index Class Reference

A Index represents the index structure. More...

#include <mknn_index.hpp>

Public Member Functions

IndexParamsgetParameters ()
 Returns the parameters used to create or load the index. More...
 
DatasetgetSearchDataset ()
 Returns the dataset used to create or load the index. More...
 
DistancegetDistance ()
 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 &parameters_resolver)
 Configures a new similarity search using the given index. More...
 
 Index ()
 Default constructor.
 
virtual ~Index ()
 Default destructor.
 
 Index (const Index &other)
 Copy constructor.
 
Indexoperator= (const Index &other)
 Assignment operator.
 

Static Public Member Functions

static Index newPredefined (IndexParams &parameters, 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
 

Detailed Description

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:

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.

Note
The complete list of pre-defined indexes provided by MetricKnn can be printed by calling PredefIndex::helpListIndexes. The parameters supported by each index can be printed by calling PredefIndex::helpPrintIndex.

Member Function Documentation

Distance& mknn::Index::getDistance ( )

Returns the distance used to create or load the index.

Returns
the distance used to create or load the index.
std::string mknn::Index::getIdPredefinedIndex ( )

returns the id of the predefined index.

Returns
the id of the predefined index.
IndexParams& mknn::Index::getParameters ( )

Returns the parameters used to create or load the index.

Returns
the parameters used to create or load the index.
Dataset& mknn::Index::getSearchDataset ( )

Returns the dataset used to create or load the index.

Returns
the dataset used to create or load the index.
static Index mknn::Index::newPredefined ( IndexParams parameters,
Dataset search_dataset,
Distance distance 
)
static

Instantiates a new index identified by the given parameters.

Parameters
parametersthe definition of the index.
delete_parameters_on_index_releasebinds the lifetime of parameters to the new index.
search_datasetthe data to be indexed. Any search on this index will return some object from search_data.
delete_search_dataset_on_index_releasebinds the lifetime of search_dataset to the new index.
distancea distance.
delete_distance_on_index_releasebinds the lifetime of distance to the new index.
Returns
a index (must be released)
Resolver mknn::Index::newResolver ( ResolverParams parameters_resolver)

Configures a new similarity search using the given index.

Parameters
parameters_resolverparameters to be given to the index in order to resolve the search.
delete_parameters_on_resolver_releasebinds the lifetime of parameters_resolver to the new resolver.
Returns
an object configured to resolve a similarity search.
static Index mknn::Index::restore ( std::string  filename_read,
Dataset search_dataset,
Distance distance,
IndexParams more_parameters 
)
static

Loads an index from a file.

The file must have been created by save.

Remarks
search_dataset and dist_factory must be the same that were used to create and save the index.
Parameters
filename_readFile to read. If the file does not exists an error is raised.
search_datasetThe search dataset that was used to build the index.
delete_search_dataset_on_index_releasebinds the lifetime of search_dataset to the new index.
distanceThe distance that was used to build the index.
delete_distance_on_index_releasebinds the lifetime of distance to the new index.
more_parametersany parameter that may override the stored parameters or new parameters that could not be saved.
delete_parameters_on_index_releasebinds the lifetime of more_parameters to the new index.
Returns
a new index (it must be released with delete).
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.

Remarks
The search_dataset is not saved and the distance factory are not saved.
Parameters
filename_writeFile to create. If the file already exists it is overwritten.

The documentation for this class was generated from the following file:
Powered by Download MetricKnn