MetricKnn API
Fast Similarity Search using the Metric Space Approach
|
A MknnIndex represents the index structure. More...
#include "../metricknn_c.h"
Go to the source code of this file.
Functions | |
MknnIndex * | mknn_index_newPredefined (MknnIndexParams *parameters, bool free_parameters_on_index_release, MknnDataset *search_dataset, bool free_search_dataset_on_index_release, MknnDistance *distance, bool free_distance_on_index_release) |
Instantiates a new index identified by the given parameters. More... | |
MknnIndexParams * | mknn_index_getParameters (MknnIndex *index) |
Returns the parameters used to create or load the index. More... | |
MknnDataset * | mknn_index_getSearchDataset (MknnIndex *index) |
Returns the dataset used to create or load the index. More... | |
MknnDistance * | mknn_index_getDistance (MknnIndex *index) |
Returns the distance used to create or load the index. More... | |
const char * | mknn_index_getIdPredefinedIndex (MknnIndex *index) |
returns the id of the predefined index. More... | |
void | mknn_index_save (MknnIndex *index, const char *filename_write) |
Saves the built index to a file. More... | |
MknnIndex * | mknn_index_restore (const char *filename_read, MknnDataset *search_dataset, bool free_search_dataset_on_index_release, MknnDistance *distance, bool free_distance_on_index_release, MknnIndexParams *more_parameters, bool free_parameters_on_index_release) |
Loads an index from a file. More... | |
MknnResolver * | mknn_index_newResolver (MknnIndex *index, MknnResolverParams *parameters_resolver, bool free_parameters_on_resolver_release) |
Configures a new similarity search using the given index. More... | |
void | mknn_index_release (MknnIndex *index) |
Releases the index. More... | |
A MknnIndex 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 function that returns the parameters for building the different indexes with mknn_index_newPredefined.
MknnDistance* mknn_index_getDistance | ( | MknnIndex * | index | ) |
Returns the distance used to create or load the index.
index | the index |
const char* mknn_index_getIdPredefinedIndex | ( | MknnIndex * | index | ) |
returns the id of the predefined index.
index | the index |
MknnIndexParams* mknn_index_getParameters | ( | MknnIndex * | index | ) |
Returns the parameters used to create or load the index.
index | the index |
MknnDataset* mknn_index_getSearchDataset | ( | MknnIndex * | index | ) |
Returns the dataset used to create or load the index.
index | the index |
MknnIndex* mknn_index_newPredefined | ( | MknnIndexParams * | parameters, |
bool | free_parameters_on_index_release, | ||
MknnDataset * | search_dataset, | ||
bool | free_search_dataset_on_index_release, | ||
MknnDistance * | distance, | ||
bool | free_distance_on_index_release | ||
) |
Instantiates a new index identified by the given parameters.
parameters | the definition of the index. |
free_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 . |
free_search_dataset_on_index_release | binds the lifetime of search_dataset to the new index. |
distance | a distance. |
free_distance_on_index_release | binds the lifetime of distance to the new index. |
MknnResolver* mknn_index_newResolver | ( | MknnIndex * | index, |
MknnResolverParams * | parameters_resolver, | ||
bool | free_parameters_on_resolver_release | ||
) |
Configures a new similarity search using the given index.
index | the index that will resolve the search. |
parameters_resolver | parameters to be given to the index in order to resolve the search. |
free_parameters_on_resolver_release | true if parameters_resolver must be released during mknn_resolver_release. |
void mknn_index_release | ( | MknnIndex * | index | ) |
Releases the index.
index | the index to be released. |
MknnIndex* mknn_index_restore | ( | const char * | filename_read, |
MknnDataset * | search_dataset, | ||
bool | free_search_dataset_on_index_release, | ||
MknnDistance * | distance, | ||
bool | free_distance_on_index_release, | ||
MknnIndexParams * | more_parameters, | ||
bool | free_parameters_on_index_release | ||
) |
Loads an index from a file.
The file must have been created by mknn_index_save.
search_dataset
and distance
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. |
free_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. |
free_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. |
free_parameters_on_index_release | binds the lifetime of more_parameters to the new index. |
void mknn_index_save | ( | MknnIndex * | index, |
const char * | 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. |
index | the index to save |