Coverage Report

Created: 2024-09-08 07:17

/src/rocksdb/util/murmurhash.h
Line
Count
Source (jump to first uncovered line)
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
15
#include "rocksdb/slice.h"
16
17
#if defined(__x86_64__)
18
#define MURMUR_HASH MurmurHash64A
19
uint64_t MurmurHash64A(const void* key, int len, unsigned int seed);
20
0
#define MurmurHash MurmurHash64A
21
using murmur_t = uint64_t;
22
23
#elif defined(__i386__)
24
#define MURMUR_HASH MurmurHash2
25
unsigned int MurmurHash2(const void* key, int len, unsigned int seed);
26
#define MurmurHash MurmurHash2
27
using murmur_t = unsigned int;
28
29
#else
30
#define MURMUR_HASH MurmurHashNeutral2
31
unsigned int MurmurHashNeutral2(const void* key, int len, unsigned int seed);
32
#define MurmurHash MurmurHashNeutral2
33
using murmur_t = unsigned int;
34
#endif
35
36
// Allow slice to be hashable by murmur hash.
37
namespace ROCKSDB_NAMESPACE {
38
struct murmur_hash {
39
0
  size_t operator()(const Slice& slice) const {
40
0
    return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0);
41
0
  }
42
};
43
}  // namespace ROCKSDB_NAMESPACE