]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/util/murmurhash.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / util / murmurhash.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
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).
7c673cae
FG
5//
6/*
7 Murmurhash from http://sites.google.com/site/murmurhash/
8
11fdf7f2
TL
9 All code is released to the public domain. For business purposes, Murmurhash
10 is under the MIT license.
7c673cae
FG
11*/
12#pragma once
13#include <stdint.h>
1e59de90 14
7c673cae
FG
15#include "rocksdb/slice.h"
16
17#if defined(__x86_64__)
18#define MURMUR_HASH MurmurHash64A
1e59de90 19uint64_t MurmurHash64A(const void* key, int len, unsigned int seed);
7c673cae 20#define MurmurHash MurmurHash64A
1e59de90 21using murmur_t = uint64_t;
7c673cae
FG
22
23#elif defined(__i386__)
24#define MURMUR_HASH MurmurHash2
1e59de90 25unsigned int MurmurHash2(const void* key, int len, unsigned int seed);
7c673cae 26#define MurmurHash MurmurHash2
1e59de90 27using murmur_t = unsigned int;
7c673cae
FG
28
29#else
30#define MURMUR_HASH MurmurHashNeutral2
1e59de90 31unsigned int MurmurHashNeutral2(const void* key, int len, unsigned int seed);
7c673cae 32#define MurmurHash MurmurHashNeutral2
1e59de90 33using murmur_t = unsigned int;
7c673cae
FG
34#endif
35
36// Allow slice to be hashable by murmur hash.
f67539c2 37namespace ROCKSDB_NAMESPACE {
7c673cae
FG
38struct murmur_hash {
39 size_t operator()(const Slice& slice) const {
40 return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0);
41 }
42};
f67539c2 43} // namespace ROCKSDB_NAMESPACE