]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/util/murmurhash.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
7 Murmurhash from http://sites.google.com/site/murmurhash/
9 All code is released to the public domain. For business purposes, Murmurhash
10 is under the MIT license.
14 #include "rocksdb/slice.h"
16 #if defined(__x86_64__)
17 #define MURMUR_HASH MurmurHash64A
18 uint64_t MurmurHash64A ( const void * key
, int len
, unsigned int seed
);
19 #define MurmurHash MurmurHash64A
20 typedef uint64_t murmur_t
;
22 #elif defined(__i386__)
23 #define MURMUR_HASH MurmurHash2
24 unsigned int MurmurHash2 ( const void * key
, int len
, unsigned int seed
);
25 #define MurmurHash MurmurHash2
26 typedef unsigned int murmur_t
;
29 #define MURMUR_HASH MurmurHashNeutral2
30 unsigned int MurmurHashNeutral2 ( const void * key
, int len
, unsigned int seed
);
31 #define MurmurHash MurmurHashNeutral2
32 typedef unsigned int murmur_t
;
35 // Allow slice to be hashable by murmur hash.
36 namespace ROCKSDB_NAMESPACE
{
38 size_t operator()(const Slice
& slice
) const {
39 return MurmurHash(slice
.data(), static_cast<int>(slice
.size()), 0);
42 } // namespace ROCKSDB_NAMESPACE