forked from ZJULearning/nsg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.h
56 lines (40 loc) · 1.13 KB
/
index.h
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
//
// Copyright (c) 2017 ZJULearning. All rights reserved.
//
// This source code is licensed under the MIT license.
//
#ifndef EFANNA2E_INDEX_H
#define EFANNA2E_INDEX_H
#include <cstddef>
#include <string>
#include <vector>
#include <fstream>
#include "distance.h"
#include "parameters.h"
namespace efanna2e {
class Index {
public:
explicit Index(const size_t dimension, const size_t n, Metric metric);
virtual ~Index();
virtual void Build(size_t n, const float *data, const Parameters ¶meters) = 0;
virtual void Search(
const float *query,
const float *x,
size_t k,
const Parameters ¶meters,
unsigned *indices) = 0;
virtual void Save(const char *filename) = 0;
virtual void Load(const char *filename) = 0;
inline bool HasBuilt() const { return has_built; }
inline size_t GetDimension() const { return dimension_; };
inline size_t GetSizeOfDataset() const { return nd_; }
inline const float *GetDataset() const { return data_; }
protected:
const size_t dimension_;
const float *data_;
size_t nd_;
bool has_built;
Distance* distance_;
};
}
#endif //EFANNA2E_INDEX_H