hash128.h 838 B

1234567891011121314151617181920212223242526
  1. // Copyright (c) Facebook, Inc. and its affiliates. 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. #pragma once
  6. // 128-bit hash gets it own header so that more popular hash.h doesn't
  7. // depend on math128.h
  8. #include "rocksdb/slice.h"
  9. #include "util/math128.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. // Stable/persistent 128-bit hash for non-cryptographic applications.
  12. Unsigned128 Hash128(const char* data, size_t n, uint64_t seed);
  13. // Specific optimization without seed (same as seed = 0)
  14. Unsigned128 Hash128(const char* data, size_t n);
  15. inline Unsigned128 GetSliceHash128(const Slice& key) {
  16. return Hash128(key.data(), key.size());
  17. }
  18. } // namespace ROCKSDB_NAMESPACE