MultiIndex
|
#include <searcher.h>
Public Member Functions | |
MultiSearcher () | |
void | Init (const string &index_files_prefix, const string &coarse_vocabs_filename, const string &fine_vocabs_filename, const RerankMode &mode, const int subspace_centroids_to_consider, bool do_rerank) |
void | GetNearestNeighbours (const Point &point, int k, vector< pair< Distance, MetaInfo > > *neighbours) const |
PerfTester & | GetPerfTester () |
Private Member Functions | |
void | DeserializeData (const string &index_files_prefix, const string &coarse_vocabs_filename, const string &fine_vocabs_filename) |
void | GetNearestSubspacesCentroids (const Point &point, const int subspace_centroins_count, vector< NearestSubspaceCentroids > *subspaces_short_lists) const |
bool | TraverseNextMultiIndexCell (const Point &point, vector< pair< Distance, MetaInfo > > *nearest_subpoints) const |
void | GetCellEdgesInMultiIndexArray (const vector< int > &cell_coordinates, int *cell_start, int *cell_finish) const |
void | InitBlasStructures () |
Private Attributes | |
vector< Centroids > | coarse_vocabs_ |
vector< Centroids > | fine_vocabs_ |
OrderedListsMerger< Distance, ClusterId > | merger_ |
bool | do_rerank_ |
PerfTester | perf_tester_ |
string | index_files_prefix_ |
MultiIndex< Record > | multiindex_ |
RerankMode | rerank_mode_ |
vector< float * > | coarse_vocabs_matrices_ |
vector< vector< float > > | coarse_centroids_norms_ |
Coord * | products_ |
vector< Coord > | query_norms_ |
float * | residual_ |
int | subspace_centroids_to_consider_ |
int | found_neghbours_count_ |
This is the main class for nearest neighbour search using multiindex
MultiSearcher< Record, MetaInfo >::MultiSearcher | ( | ) |
Default constructor
void MultiSearcher< Record, MetaInfo >::DeserializeData | ( | const string & | index_files_prefix, |
const string & | coarse_vocabs_filename, | ||
const string & | fine_vocabs_filename | ||
) | [private] |
This functions deserializes all structures for search
index_files_prefix | prefix of multiindex files providing the search |
coarse_vocabs_filename | file with coarse vocabs |
fine_vocabs_filename | file with fine vocabs for reranking |
void MultiSearcher< Record, MetaInfo >::GetCellEdgesInMultiIndexArray | ( | const vector< int > & | cell_coordinates, |
int * | cell_start, | ||
int * | cell_finish | ||
) | const [inline, private] |
This fuctions converts cells coordinates to appropriate range in array
cell_coordinates | coordinates of the cell |
cell_start | first index of range |
cell_finish | last index of range |
void MultiSearcher< Record, MetaInfo >::GetNearestNeighbours | ( | const Point & | point, |
int | k, | ||
vector< pair< Distance, MetaInfo > > * | neighbours | ||
) | const |
Main interface function
point | query point |
k | number of neighbours to get |
subpace_centroids_to_consider | it defines the size of working index table |
neighbours | result - vector of point identifiers ordered by increasing of distance to query |
void MultiSearcher< Record, MetaInfo >::GetNearestSubspacesCentroids | ( | const Point & | point, |
const int | subspace_centroins_count, | ||
vector< NearestSubspaceCentroids > * | subspaces_short_lists | ||
) | const [private] |
Function gets some nearest centroids for each coarse subspace
point | query point |
subspace_centroins_count | how many nearest subcentroids to get |
subspaces_short_lists | result |
PerfTester & MultiSearcher< Record, MetaInfo >::GetPerfTester | ( | ) |
Returns searcher perfomance tester
void MultiSearcher< Record, MetaInfo >::Init | ( | const string & | index_files_prefix, |
const string & | coarse_vocabs_filename, | ||
const string & | fine_vocabs_filename, | ||
const RerankMode & | mode, | ||
const int | subspace_centroids_to_consider, | ||
bool | do_rerank | ||
) |
Initiation function
index_files_prefix | prefix of multiindex files providing the search |
coarse_vocabs_filename | file with coarse vocabs |
fine_vocabs_filename | file with fine vocabs for reranking |
mode | reranking approach |
do_rerank | should algorithm rerank short list or not |
void MultiSearcher< Record, MetaInfo >::InitBlasStructures | ( | ) | [private] |
This fuctions converts complex objects to arrays and pointers for usage in BLAS
bool MultiSearcher< Record, MetaInfo >::TraverseNextMultiIndexCell | ( | const Point & | point, |
vector< pair< Distance, MetaInfo > > * | nearest_subpoints | ||
) | const [private] |
This fuctions traverses another cell of multiindex table
point | query point |
nearest_subpoints | vector algorithm adds nearest neighbours in |
vector<vector<float> > MultiSearcher< Record, MetaInfo >::coarse_centroids_norms_ [private] |
Struct for BLAS
vector<Centroids> MultiSearcher< Record, MetaInfo >::coarse_vocabs_ [private] |
Lists of coarse centroids
vector<float*> MultiSearcher< Record, MetaInfo >::coarse_vocabs_matrices_ [private] |
Struct for BLAS
bool MultiSearcher< Record, MetaInfo >::do_rerank_ [private] |
Should algorithm use reranking or not
vector<Centroids> MultiSearcher< Record, MetaInfo >::fine_vocabs_ [private] |
Lists of fine centroids
int MultiSearcher< Record, MetaInfo >::found_neghbours_count_ [mutable, private] |
Number of neighbours found to this moment
string MultiSearcher< Record, MetaInfo >::index_files_prefix_ [private] |
Common prefix of every index files
OrderedListsMerger<Distance, ClusterId> MultiSearcher< Record, MetaInfo >::merger_ [mutable, private] |
Merger for ordered merging subspaces centroids lists
MultiIndex<Record> MultiSearcher< Record, MetaInfo >::multiindex_ [private] |
Multiindex data structures
PerfTester MultiSearcher< Record, MetaInfo >::perf_tester_ [mutable, private] |
Searcher perfomance tester
Coord* MultiSearcher< Record, MetaInfo >::products_ [mutable, private] |
Struct for BLAS
vector<Coord> MultiSearcher< Record, MetaInfo >::query_norms_ [mutable, private] |
Struct for BLAS
RerankMode MultiSearcher< Record, MetaInfo >::rerank_mode_ [private] |
Reranking approach
float* MultiSearcher< Record, MetaInfo >::residual_ [mutable, private] |
Struct for BLAS
int MultiSearcher< Record, MetaInfo >::subspace_centroids_to_consider_ [private] |
Number of nearest to query centroids to consider for each dimension