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). 5 // 6 /* 7 Murmurhash from http://sites.google.com/site/murmurhash/ 8 9 All code is released to the public domain. For business purposes, Murmurhash 10 is under the MIT license. 11 */ 12 #pragma once 13 #include <stdint.h> 14 #include "rocksdb/slice.h" 15 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; 21 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; 27 28 #else 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; 33 #endif 34 35 // Allow slice to be hashable by murmur hash. 36 namespace ROCKSDB_NAMESPACE { 37 struct murmur_hash { operatormurmur_hash38 size_t operator()(const Slice& slice) const { 39 return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0); 40 } 41 }; 42 } // namespace ROCKSDB_NAMESPACE 43