forked from fastio/1store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.cc
75 lines (66 loc) · 1.68 KB
/
token.cc
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
#include "token.hh"
namespace redis {
static const token min_token{ token::kind::before_all_keys, {} };
static const token max_token{ token::kind::after_all_keys, {} };
const token&
minimum_token() {
return min_token;
}
const token&
maximum_token() {
return max_token;
}
token token::from_bytes(const bytes& key) {
return minimum_token();
}
token token::from_bytes(const bytes_view& key) {
return minimum_token();
}
bool operator==(const token& t1, const token& t2)
{
/*
if (t1._kind != t2._kind) {
return false;
} else if (t1._kind == token::kind::key) {
return global_partitioner().is_equal(t1, t2);
}
*/
return true;
}
bool operator<(const token& t1, const token& t2)
{
/*
if (t1._kind < t2._kind) {
return true;
} else if (t1._kind == token::kind::key && t2._kind == token::kind::key) {
return global_partitioner().is_less(t1, t2);
}
*/
return false;
}
std::ostream& operator<<(std::ostream& out, const token& t) {
/*
if (t._kind == token::kind::after_all_keys) {
out << "maximum token";
} else if (t._kind == token::kind::before_all_keys) {
out << "minimum token";
} else {
out << global_partitioner().to_sstring(t);
}
*/
return out;
}
}
namespace std {
size_t
hash<redis::token>::hash_large_token(const managed_bytes& b) const {
/*
auto read_bytes = boost::irange<size_t>(0, b.size())
| boost::adaptors::transformed([&b] (size_t idx) { return b[idx]; });
std::array<uint64_t, 2> result;
utils::murmur_hash::hash3_x64_128(read_bytes.begin(), b.size(), 0, result);
return result[0];
*/
return 0;
}
}