]> git.sesse.net Git - remoteglot-book/blob - hash.cpp
Partition the SSTable; somewhat less efficient space-wise, it seems, but we avoid...
[remoteglot-book] / hash.cpp
1 #include <farmhash.h>
2 #include <algorithm>
3 #include "hash.h"
4
5 using namespace std;
6
7 int hash_key_to_bucket(const char* s, size_t len, int num_buckets)
8 {
9         // We hash only the first 10 bytes; it should be enough to get a
10         // reasonable spread, but also mostly miss the move, so that
11         // same position + different move usually land in the same bucket.
12         len = max<size_t>(len, 10);
13         return util::Fingerprint32(s, len) % num_buckets;
14 }