-
Notifications
You must be signed in to change notification settings - Fork 5
/
efanna.hpp
51 lines (48 loc) · 1.32 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
// Copyright (C) 2018 Deng Cai <dengcai@gmail.com>. 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(float* data, size_t points_num, int dim)
{
initIndex_->buildIndex(data, points_num, dim);
}
void saveIndex(char* filename){
initIndex_->saveIndex(filename);
}
void loadIndex(char* filename){
initIndex_->loadIndex(filename);
}
void setSearchParams(int tables, int init_num){
initIndex_->setSearchParams(tables, init_num);
}
void knnSearch(int k, const Matrix<DataType>& query, float* query_){
initIndex_->knnSearch(k, query, query_);
}
void saveResults(char* filename){
initIndex_->saveResults(filename);
}
private:
/** Pointer to actual index class */
IndexType* initIndex_;
/** Parameters passed to the index */
IndexParams index_params_;
};
}
#endif