/Users/deen/code/yugabyte-db/src/yb/rocksdb/util/murmurhash.h
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | /* |
21 | | Murmurhash from http://sites.google.com/site/murmurhash/ |
22 | | |
23 | | All code is released to the public domain. For business purposes, Murmurhash is |
24 | | under the MIT license. |
25 | | */ |
26 | | #pragma once |
27 | | #include <stdint.h> |
28 | | #include "yb/util/slice.h" |
29 | | |
30 | | #if defined(__x86_64__) |
31 | | #define MURMUR_HASH MurmurHash64A |
32 | | uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed ); |
33 | | #define MurmurHash MurmurHash64A |
34 | | typedef uint64_t murmur_t; |
35 | | |
36 | | #elif defined(__i386__) |
37 | | #define MURMUR_HASH MurmurHash2 |
38 | | unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed ); |
39 | | #define MurmurHash MurmurHash2 |
40 | | typedef unsigned int murmur_t; |
41 | | |
42 | | #else |
43 | | #define MURMUR_HASH MurmurHashNeutral2 |
44 | | unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed ); |
45 | 3.82M | #define MurmurHash MurmurHashNeutral2 |
46 | | typedef unsigned int murmur_t; |
47 | | #endif |
48 | | |
49 | | // Allow slice to be hashable by murmur hash. |
50 | | namespace rocksdb { |
51 | | struct murmur_hash { |
52 | 1.01M | size_t operator()(const Slice& slice) const { |
53 | 1.01M | return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0); |
54 | 1.01M | } |
55 | | }; |
56 | | } // rocksdb |