22161b7547
Summary: With expected use for a 128-bit hash, xxhash library is upgraded to current dev (2c611a76f914828bed675f0f342d6c4199ffee1e) as of Aug 6 so that we can use production version of XXH3_128bits as new Hash128 function (added in hash128.h). To make this work, however, we have to carve out the "preview" version of XXH3 that is used in new SST Bloom and Ribbon filters, since that will not get maintenance in xxhash releases. I have consolidated all the relevant code into xxph3.h and made it "inline only" (no .cc file). The working name for this hash function is changed from XXH3p to XXPH3 (XX Preview Hash) because the latter is easier to get working with no symbol name conflicts between the headers. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8634 Test Plan: no expected change in existing functionality. For Hash128, added some unit tests based on those for Hash64 to ensure some basic properties and that the values do not change accidentally. Reviewed By: zhichao-cao Differential Revision: D30173490 Pulled By: pdillinger fbshipit-source-id: 06aa542a7a28b353bc2c865b9b2f8bdfe44158e4
27 lines
838 B
C++
27 lines
838 B
C++
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
// 128-bit hash gets it own header so that more popular hash.h doesn't
|
|
// depend on math128.h
|
|
|
|
#include "rocksdb/slice.h"
|
|
#include "util/math128.h"
|
|
|
|
namespace ROCKSDB_NAMESPACE {
|
|
|
|
// Stable/persistent 128-bit hash for non-cryptographic applications.
|
|
Unsigned128 Hash128(const char* data, size_t n, uint64_t seed);
|
|
|
|
// Specific optimization without seed (same as seed = 0)
|
|
Unsigned128 Hash128(const char* data, size_t n);
|
|
|
|
inline Unsigned128 GetSliceHash128(const Slice& key) {
|
|
return Hash128(key.data(), key.size());
|
|
}
|
|
|
|
} // namespace ROCKSDB_NAMESPACE
|