forked from stanis-morozov/ip-nsw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hnswlib.h
41 lines (33 loc) · 984 Bytes
/
hnswlib.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
#pragma once
#ifdef _MSC_VER
#include <intrin.h>
#include <stdexcept>
#define __builtin_popcount(t) __popcnt(t)
#endif
typedef size_t labeltype;
#if defined(__GNUC__)
#define PORTABLE_ALIGN32 __attribute__((aligned(32)))
#else
#define PORTABLE_ALIGN32 __declspec(align(32))
#endif
namespace hnswlib {
//typedef void *labeltype;
//typedef float(*DISTFUNC) (const void *, const void *, const void *);
template<typename MTYPE>
using DISTFUNC = MTYPE(*) (const void *, const void *, const void *);
template <typename dist_t> class AlgorithmInterface {
public:
//virtual void addPoint(void *, labeltype) = 0;
virtual std::priority_queue< std::pair< dist_t, labeltype >> searchKnn(void *,int) = 0;
};
template<typename MTYPE>
class SpaceInterface {
public:
//virtual void search(void *);
virtual size_t get_data_size() = 0;
virtual DISTFUNC<MTYPE> get_dist_func() = 0;
virtual void *get_dist_func_param() = 0;
};
}
#include "L2space.h"
#include "hnswalg.h"