-
Notifications
You must be signed in to change notification settings - Fork 6
/
efanna.hpp
80 lines (76 loc) · 1.94 KB
/
efanna.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2016 Cong Fu <[email protected]>. All Rights Reserved.
#ifndef EFANNA
#define EFANNA
#include "general/distance.hpp"
#include "general/matrix.hpp"
#include "general/params.hpp"
#include "algorithm/init_indices.hpp"
namespace efanna{
template <typename DataType>
class FIndex{
public:
typedef InitIndex<DataType> IndexType;
FIndex(const Matrix<DataType>& features, Distance<DataType>* d, const IndexParams& params)
: index_params_(params)
{
init_algorithm init_index_type= params.init_index_type;
index_params_ = params;
initIndex_ = create_index_by_type(init_index_type, features, params, d);
}
virtual ~FIndex () {
}
void buildIndex()
{
initIndex_->buildIndex();
}
void buildTrees()
{
initIndex_->buildTrees();
}
void knnSearch(int k, const Matrix<DataType>& query){
initIndex_->knnSearch(k, query);
}
void locatPoints(const Matrix<DataType>& query){
initIndex_->locatPoints(query);
}
void saveIndex(char* filename){
initIndex_->saveIndex(filename);
}
void loadIndex(char* filename){
initIndex_->loadIndex(filename);
}
void saveTrees(char* filename){
initIndex_->saveTrees(filename);
}
void loadTrees(char* filename){
initIndex_->loadTrees(filename);
}
void saveGraph(char* filename){
initIndex_->saveGraph(filename);
}
void loadGraph(char* filename){
initIndex_->loadGraph(filename);
}
void saveResults(char* filename){
initIndex_->saveResults(filename);
}
void setSearchParams(int epochs, int init_num, int extend_to, int search_method = 0){
initIndex_->setSearchParams(epochs, init_num, extend_to, search_method);
}
size_t getGraphSize(){
return initIndex_->getGraphSize();
}
std::vector<unsigned> getGraphRow(unsigned row_id){
return initIndex_->getGraphRow(row_id);
}
void outputVisitBucketNum(){
initIndex_->outputVisitBucketNum();
}
private:
/** Pointer to actual index class */
IndexType* initIndex_;
/** Parameters passed to the index */
IndexParams index_params_;
};
}
#endif