blob: 13964e86208142ea454f1861e54a74fe8c597dba (
plain)
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
|
#pragma once
#include <cstdlib>
#include "psu-ds/BTree.h"
#include "framework/interface/Record.h"
#include "pgm/pgm_index_dynamic.hpp"
/* BTree definitions*/
template <typename K, typename V>
struct btree_record {
K key;
V value;
inline bool operator<(const btree_record& other) const {
return key < other.key || (key == other.key && value < other.value);
}
inline bool operator==(const btree_record& other) const {
return key == other.key && value == other.value;
}
};
template <typename K, typename V>
struct btree_key_extract {
static const K &get(const btree_record<K, V> &v) {
return v.key;
}
};
typedef psudb::BTree<int64_t, btree_record<int64_t, int64_t>, btree_key_extract<int64_t, int64_t>> BenchBTree;
/*MTree Definitions*/
const size_t W2V_SIZE = 300;
typedef de::EuclidPoint<double, W2V_SIZE> Word2VecRec;
struct euclidean_distance {
double operator()(const Word2VecRec &first, const Word2VecRec &second) const {
double dist = 0;
for (size_t i=0; i<W2V_SIZE; i++) {
dist += (first.data[i] - second.data[i]) * (first.data[i] - second.data[i]);
}
return std::sqrt(dist);
}
};
#ifdef _GNU_SOURCE
#include "mtree.h"
typedef mt::mtree<Word2VecRec, euclidean_distance> MTree;
#endif
typedef pgm::DynamicPGMIndex<uint64_t, uint64_t, pgm::PGMIndex<uint64_t, 64>> PGM;
|