Repo created
This commit is contained in:
parent
81b91f4139
commit
f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions
448
TMessagesProj/jni/voip/webrtc/absl/hash/hash.h
Normal file
448
TMessagesProj/jni/voip/webrtc/absl/hash/hash.h
Normal file
|
|
@ -0,0 +1,448 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// File: hash.h
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// This header file defines the Abseil `hash` library and the Abseil hashing
|
||||
// framework. This framework consists of the following:
|
||||
//
|
||||
// * The `absl::Hash` functor, which is used to invoke the hasher within the
|
||||
// Abseil hashing framework. `absl::Hash<T>` supports most basic types and
|
||||
// a number of Abseil types out of the box.
|
||||
// * `AbslHashValue`, an extension point that allows you to extend types to
|
||||
// support Abseil hashing without requiring you to define a hashing
|
||||
// algorithm.
|
||||
// * `HashState`, a type-erased class which implements the manipulation of the
|
||||
// hash state (H) itself; contains member functions `combine()`,
|
||||
// `combine_contiguous()`, and `combine_unordered()`; and which you can use
|
||||
// to contribute to an existing hash state when hashing your types.
|
||||
//
|
||||
// Unlike `std::hash` or other hashing frameworks, the Abseil hashing framework
|
||||
// provides most of its utility by abstracting away the hash algorithm (and its
|
||||
// implementation) entirely. Instead, a type invokes the Abseil hashing
|
||||
// framework by simply combining its state with the state of known, hashable
|
||||
// types. Hashing of that combined state is separately done by `absl::Hash`.
|
||||
//
|
||||
// One should assume that a hash algorithm is chosen randomly at the start of
|
||||
// each process. E.g., `absl::Hash<int>{}(9)` in one process and
|
||||
// `absl::Hash<int>{}(9)` in another process are likely to differ.
|
||||
//
|
||||
// `absl::Hash` may also produce different values from different dynamically
|
||||
// loaded libraries. For this reason, `absl::Hash` values must never cross
|
||||
// boundaries in dynamically loaded libraries (including when used in types like
|
||||
// hash containers.)
|
||||
//
|
||||
// `absl::Hash` is intended to strongly mix input bits with a target of passing
|
||||
// an [Avalanche Test](https://en.wikipedia.org/wiki/Avalanche_effect).
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// // Suppose we have a class `Circle` for which we want to add hashing:
|
||||
// class Circle {
|
||||
// public:
|
||||
// ...
|
||||
// private:
|
||||
// std::pair<int, int> center_;
|
||||
// int radius_;
|
||||
// };
|
||||
//
|
||||
// // To add hashing support to `Circle`, we simply need to add a free
|
||||
// // (non-member) function `AbslHashValue()`, and return the combined hash
|
||||
// // state of the existing hash state and the class state. You can add such a
|
||||
// // free function using a friend declaration within the body of the class:
|
||||
// class Circle {
|
||||
// public:
|
||||
// ...
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H h, const Circle& c) {
|
||||
// return H::combine(std::move(h), c.center_, c.radius_);
|
||||
// }
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
// For more information, see Adding Type Support to `absl::Hash` below.
|
||||
//
|
||||
#ifndef ABSL_HASH_HASH_H_
|
||||
#define ABSL_HASH_HASH_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/functional/function_ref.h"
|
||||
#include "absl/hash/internal/hash.h"
|
||||
#include "absl/meta/type_traits.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// `absl::Hash`
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// `absl::Hash<T>` is a convenient general-purpose hash functor for any type `T`
|
||||
// satisfying any of the following conditions (in order):
|
||||
//
|
||||
// * T is an arithmetic or pointer type
|
||||
// * T defines an overload for `AbslHashValue(H, const T&)` for an arbitrary
|
||||
// hash state `H`.
|
||||
// - T defines a specialization of `std::hash<T>`
|
||||
//
|
||||
// `absl::Hash` intrinsically supports the following types:
|
||||
//
|
||||
// * All integral types (including bool)
|
||||
// * All enum types
|
||||
// * All floating-point types (although hashing them is discouraged)
|
||||
// * All pointer types, including nullptr_t
|
||||
// * std::pair<T1, T2>, if T1 and T2 are hashable
|
||||
// * std::tuple<Ts...>, if all the Ts... are hashable
|
||||
// * std::unique_ptr and std::shared_ptr
|
||||
// * All string-like types including:
|
||||
// * absl::Cord
|
||||
// * std::string (as well as any instance of std::basic_string that
|
||||
// uses one of {char, wchar_t, char16_t, char32_t} and its associated
|
||||
// std::char_traits)
|
||||
// * std::string_view (as well as any instance of std::basic_string_view
|
||||
// that uses one of {char, wchar_t, char16_t, char32_t} and its associated
|
||||
// std::char_traits)
|
||||
// * All the standard sequence containers (provided the elements are hashable)
|
||||
// * All the standard associative containers (provided the elements are
|
||||
// hashable)
|
||||
// * absl types such as the following:
|
||||
// * absl::string_view
|
||||
// * absl::uint128
|
||||
// * absl::Time, absl::Duration, and absl::TimeZone
|
||||
// * absl containers (provided the elements are hashable) such as the
|
||||
// following:
|
||||
// * absl::flat_hash_set, absl::node_hash_set, absl::btree_set
|
||||
// * absl::flat_hash_map, absl::node_hash_map, absl::btree_map
|
||||
// * absl::btree_multiset, absl::btree_multimap
|
||||
// * absl::InlinedVector
|
||||
// * absl::FixedArray
|
||||
//
|
||||
// When absl::Hash is used to hash an unordered container with a custom hash
|
||||
// functor, the elements are hashed using default absl::Hash semantics, not
|
||||
// the custom hash functor. This is consistent with the behavior of
|
||||
// operator==() on unordered containers, which compares elements pairwise with
|
||||
// operator==() rather than the custom equality functor. It is usually a
|
||||
// mistake to use either operator==() or absl::Hash on unordered collections
|
||||
// that use functors incompatible with operator==() equality.
|
||||
//
|
||||
// Note: the list above is not meant to be exhaustive. Additional type support
|
||||
// may be added, in which case the above list will be updated.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// absl::Hash Invocation Evaluation
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// When invoked, `absl::Hash<T>` searches for supplied hash functions in the
|
||||
// following order:
|
||||
//
|
||||
// * Natively supported types out of the box (see above)
|
||||
// * Types for which an `AbslHashValue()` overload is provided (such as
|
||||
// user-defined types). See "Adding Type Support to `absl::Hash`" below.
|
||||
// * Types which define a `std::hash<T>` specialization
|
||||
//
|
||||
// The fallback to legacy hash functions exists mainly for backwards
|
||||
// compatibility. If you have a choice, prefer defining an `AbslHashValue`
|
||||
// overload instead of specializing any legacy hash functors.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// The Hash State Concept, and using `HashState` for Type Erasure
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// The `absl::Hash` framework relies on the Concept of a "hash state." Such a
|
||||
// hash state is used in several places:
|
||||
//
|
||||
// * Within existing implementations of `absl::Hash<T>` to store the hashed
|
||||
// state of an object. Note that it is up to the implementation how it stores
|
||||
// such state. A hash table, for example, may mix the state to produce an
|
||||
// integer value; a testing framework may simply hold a vector of that state.
|
||||
// * Within implementations of `AbslHashValue()` used to extend user-defined
|
||||
// types. (See "Adding Type Support to absl::Hash" below.)
|
||||
// * Inside a `HashState`, providing type erasure for the concept of a hash
|
||||
// state, which you can use to extend the `absl::Hash` framework for types
|
||||
// that are otherwise difficult to extend using `AbslHashValue()`. (See the
|
||||
// `HashState` class below.)
|
||||
//
|
||||
// The "hash state" concept contains three member functions for mixing hash
|
||||
// state:
|
||||
//
|
||||
// * `H::combine(state, values...)`
|
||||
//
|
||||
// Combines an arbitrary number of values into a hash state, returning the
|
||||
// updated state. Note that the existing hash state is move-only and must be
|
||||
// passed by value.
|
||||
//
|
||||
// Each of the value types T must be hashable by H.
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// state = H::combine(std::move(state), value1, value2, value3);
|
||||
//
|
||||
// must be guaranteed to produce the same hash expansion as
|
||||
//
|
||||
// state = H::combine(std::move(state), value1);
|
||||
// state = H::combine(std::move(state), value2);
|
||||
// state = H::combine(std::move(state), value3);
|
||||
//
|
||||
// * `H::combine_contiguous(state, data, size)`
|
||||
//
|
||||
// Combines a contiguous array of `size` elements into a hash state,
|
||||
// returning the updated state. Note that the existing hash state is
|
||||
// move-only and must be passed by value.
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// state = H::combine_contiguous(std::move(state), data, size);
|
||||
//
|
||||
// need NOT be guaranteed to produce the same hash expansion as a loop
|
||||
// (it may perform internal optimizations). If you need this guarantee, use a
|
||||
// loop instead.
|
||||
//
|
||||
// * `H::combine_unordered(state, begin, end)`
|
||||
//
|
||||
// Combines a set of elements denoted by an iterator pair into a hash
|
||||
// state, returning the updated state. Note that the existing hash
|
||||
// state is move-only and must be passed by value.
|
||||
//
|
||||
// Unlike the other two methods, the hashing is order-independent.
|
||||
// This can be used to hash unordered collections.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// Adding Type Support to `absl::Hash`
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// To add support for your user-defined type, add a proper `AbslHashValue()`
|
||||
// overload as a free (non-member) function. The overload will take an
|
||||
// existing hash state and should combine that state with state from the type.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// template <typename H>
|
||||
// H AbslHashValue(H state, const MyType& v) {
|
||||
// return H::combine(std::move(state), v.field1, ..., v.fieldN);
|
||||
// }
|
||||
//
|
||||
// where `(field1, ..., fieldN)` are the members you would use on your
|
||||
// `operator==` to define equality.
|
||||
//
|
||||
// Notice that `AbslHashValue` is not a class member, but an ordinary function.
|
||||
// An `AbslHashValue` overload for a type should only be declared in the same
|
||||
// file and namespace as said type. The proper `AbslHashValue` implementation
|
||||
// for a given type will be discovered via ADL.
|
||||
//
|
||||
// Note: unlike `std::hash', `absl::Hash` should never be specialized. It must
|
||||
// only be extended by adding `AbslHashValue()` overloads.
|
||||
//
|
||||
template <typename T>
|
||||
using Hash = absl::hash_internal::Hash<T>;
|
||||
|
||||
// HashOf
|
||||
//
|
||||
// absl::HashOf() is a helper that generates a hash from the values of its
|
||||
// arguments. It dispatches to absl::Hash directly, as follows:
|
||||
// * HashOf(t) == absl::Hash<T>{}(t)
|
||||
// * HashOf(a, b, c) == HashOf(std::make_tuple(a, b, c))
|
||||
//
|
||||
// HashOf(a1, a2, ...) == HashOf(b1, b2, ...) is guaranteed when
|
||||
// * The argument lists have pairwise identical C++ types
|
||||
// * a1 == b1 && a2 == b2 && ...
|
||||
//
|
||||
// The requirement that the arguments match in both type and value is critical.
|
||||
// It means that `a == b` does not necessarily imply `HashOf(a) == HashOf(b)` if
|
||||
// `a` and `b` have different types. For example, `HashOf(2) != HashOf(2.0)`.
|
||||
template <int&... ExplicitArgumentBarrier, typename... Types>
|
||||
size_t HashOf(const Types&... values) {
|
||||
auto tuple = std::tie(values...);
|
||||
return absl::Hash<decltype(tuple)>{}(tuple);
|
||||
}
|
||||
|
||||
// HashState
|
||||
//
|
||||
// A type erased version of the hash state concept, for use in user-defined
|
||||
// `AbslHashValue` implementations that can't use templates (such as PImpl
|
||||
// classes, virtual functions, etc.). The type erasure adds overhead so it
|
||||
// should be avoided unless necessary.
|
||||
//
|
||||
// Note: This wrapper will only erase calls to
|
||||
// combine_contiguous(H, const unsigned char*, size_t)
|
||||
// RunCombineUnordered(H, CombinerF)
|
||||
//
|
||||
// All other calls will be handled internally and will not invoke overloads
|
||||
// provided by the wrapped class.
|
||||
//
|
||||
// Users of this class should still define a template `AbslHashValue` function,
|
||||
// but can use `absl::HashState::Create(&state)` to erase the type of the hash
|
||||
// state and dispatch to their private hashing logic.
|
||||
//
|
||||
// This state can be used like any other hash state. In particular, you can call
|
||||
// `HashState::combine()` and `HashState::combine_contiguous()` on it.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// class Interface {
|
||||
// public:
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H state, const Interface& value) {
|
||||
// state = H::combine(std::move(state), std::type_index(typeid(*this)));
|
||||
// value.HashValue(absl::HashState::Create(&state));
|
||||
// return state;
|
||||
// }
|
||||
// private:
|
||||
// virtual void HashValue(absl::HashState state) const = 0;
|
||||
// };
|
||||
//
|
||||
// class Impl : Interface {
|
||||
// private:
|
||||
// void HashValue(absl::HashState state) const override {
|
||||
// absl::HashState::combine(std::move(state), v1_, v2_);
|
||||
// }
|
||||
// int v1_;
|
||||
// std::string v2_;
|
||||
// };
|
||||
class HashState : public hash_internal::HashStateBase<HashState> {
|
||||
public:
|
||||
// HashState::Create()
|
||||
//
|
||||
// Create a new `HashState` instance that wraps `state`. All calls to
|
||||
// `combine()` and `combine_contiguous()` on the new instance will be
|
||||
// redirected to the original `state` object. The `state` object must outlive
|
||||
// the `HashState` instance. `T` must be a subclass of `HashStateBase<T>` -
|
||||
// users should not define their own HashState types.
|
||||
template <
|
||||
typename T,
|
||||
absl::enable_if_t<
|
||||
std::is_base_of<hash_internal::HashStateBase<T>, T>::value, int> = 0>
|
||||
static HashState Create(T* state) {
|
||||
HashState s;
|
||||
s.Init(state);
|
||||
return s;
|
||||
}
|
||||
|
||||
HashState(const HashState&) = delete;
|
||||
HashState& operator=(const HashState&) = delete;
|
||||
HashState(HashState&&) = default;
|
||||
HashState& operator=(HashState&&) = default;
|
||||
|
||||
// HashState::combine()
|
||||
//
|
||||
// Combines an arbitrary number of values into a hash state, returning the
|
||||
// updated state.
|
||||
using HashState::HashStateBase::combine;
|
||||
|
||||
// HashState::combine_contiguous()
|
||||
//
|
||||
// Combines a contiguous array of `size` elements into a hash state, returning
|
||||
// the updated state.
|
||||
static HashState combine_contiguous(HashState hash_state,
|
||||
const unsigned char* first, size_t size) {
|
||||
hash_state.combine_contiguous_(hash_state.state_, first, size);
|
||||
return hash_state;
|
||||
}
|
||||
using HashState::HashStateBase::combine_contiguous;
|
||||
|
||||
private:
|
||||
HashState() = default;
|
||||
|
||||
friend class HashState::HashStateBase;
|
||||
friend struct hash_internal::CombineRaw;
|
||||
|
||||
template <typename T>
|
||||
static void CombineContiguousImpl(void* p, const unsigned char* first,
|
||||
size_t size) {
|
||||
T& state = *static_cast<T*>(p);
|
||||
state = T::combine_contiguous(std::move(state), first, size);
|
||||
}
|
||||
|
||||
static HashState combine_raw(HashState hash_state, uint64_t value) {
|
||||
hash_state.combine_raw_(hash_state.state_, value);
|
||||
return hash_state;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void CombineRawImpl(void* p, uint64_t value) {
|
||||
T& state = *static_cast<T*>(p);
|
||||
state = hash_internal::CombineRaw()(std::move(state), value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Init(T* state) {
|
||||
state_ = state;
|
||||
combine_contiguous_ = &CombineContiguousImpl<T>;
|
||||
combine_raw_ = &CombineRawImpl<T>;
|
||||
run_combine_unordered_ = &RunCombineUnorderedImpl<T>;
|
||||
}
|
||||
|
||||
template <typename HS>
|
||||
struct CombineUnorderedInvoker {
|
||||
template <typename T, typename ConsumerT>
|
||||
void operator()(T inner_state, ConsumerT inner_cb) {
|
||||
f(HashState::Create(&inner_state),
|
||||
[&](HashState& inner_erased) { inner_cb(inner_erased.Real<T>()); });
|
||||
}
|
||||
|
||||
absl::FunctionRef<void(HS, absl::FunctionRef<void(HS&)>)> f;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static HashState RunCombineUnorderedImpl(
|
||||
HashState state,
|
||||
absl::FunctionRef<void(HashState, absl::FunctionRef<void(HashState&)>)>
|
||||
f) {
|
||||
// Note that this implementation assumes that inner_state and outer_state
|
||||
// are the same type. This isn't true in the SpyHash case, but SpyHash
|
||||
// types are move-convertible to each other, so this still works.
|
||||
T& real_state = state.Real<T>();
|
||||
real_state = T::RunCombineUnordered(
|
||||
std::move(real_state), CombineUnorderedInvoker<HashState>{f});
|
||||
return state;
|
||||
}
|
||||
|
||||
template <typename CombinerT>
|
||||
static HashState RunCombineUnordered(HashState state, CombinerT combiner) {
|
||||
auto* run = state.run_combine_unordered_;
|
||||
return run(std::move(state), std::ref(combiner));
|
||||
}
|
||||
|
||||
// Do not erase an already erased state.
|
||||
void Init(HashState* state) {
|
||||
state_ = state->state_;
|
||||
combine_contiguous_ = state->combine_contiguous_;
|
||||
combine_raw_ = state->combine_raw_;
|
||||
run_combine_unordered_ = state->run_combine_unordered_;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& Real() {
|
||||
return *static_cast<T*>(state_);
|
||||
}
|
||||
|
||||
void* state_;
|
||||
void (*combine_contiguous_)(void*, const unsigned char*, size_t);
|
||||
void (*combine_raw_)(void*, uint64_t);
|
||||
HashState (*run_combine_unordered_)(
|
||||
HashState state,
|
||||
absl::FunctionRef<void(HashState, absl::FunctionRef<void(HashState&)>)>);
|
||||
};
|
||||
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_HASH_H_
|
||||
384
TMessagesProj/jni/voip/webrtc/absl/hash/hash_benchmark.cc
Normal file
384
TMessagesProj/jni/voip/webrtc/absl/hash/hash_benchmark.cc
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <typeindex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/hash/hash.h"
|
||||
#include "absl/random/random.h"
|
||||
#include "absl/strings/cord.h"
|
||||
#include "absl/strings/cord_test_helpers.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using absl::Hash;
|
||||
|
||||
template <template <typename> class H, typename T>
|
||||
void RunBenchmark(benchmark::State& state, T value) {
|
||||
H<T> h;
|
||||
for (auto _ : state) {
|
||||
benchmark::DoNotOptimize(value);
|
||||
benchmark::DoNotOptimize(h(value));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
template <typename T>
|
||||
using AbslHash = absl::Hash<T>;
|
||||
|
||||
class TypeErasedInterface {
|
||||
public:
|
||||
virtual ~TypeErasedInterface() = default;
|
||||
|
||||
template <typename H>
|
||||
friend H AbslHashValue(H state, const TypeErasedInterface& wrapper) {
|
||||
state = H::combine(std::move(state), std::type_index(typeid(wrapper)));
|
||||
wrapper.HashValue(absl::HashState::Create(&state));
|
||||
return state;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void HashValue(absl::HashState state) const = 0;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TypeErasedAbslHash {
|
||||
class Wrapper : public TypeErasedInterface {
|
||||
public:
|
||||
explicit Wrapper(const T& value) : value_(value) {}
|
||||
|
||||
private:
|
||||
void HashValue(absl::HashState state) const override {
|
||||
absl::HashState::combine(std::move(state), value_);
|
||||
}
|
||||
|
||||
const T& value_;
|
||||
};
|
||||
|
||||
size_t operator()(const T& value) {
|
||||
return absl::Hash<Wrapper>{}(Wrapper(value));
|
||||
}
|
||||
};
|
||||
|
||||
absl::Cord FlatCord(size_t size) {
|
||||
absl::Cord result(std::string(size, 'a'));
|
||||
result.Flatten();
|
||||
return result;
|
||||
}
|
||||
|
||||
absl::Cord FragmentedCord(size_t size) {
|
||||
const size_t orig_size = size;
|
||||
std::vector<std::string> chunks;
|
||||
size_t chunk_size = std::max<size_t>(1, size / 10);
|
||||
while (size > chunk_size) {
|
||||
chunks.push_back(std::string(chunk_size, 'a'));
|
||||
size -= chunk_size;
|
||||
}
|
||||
if (size > 0) {
|
||||
chunks.push_back(std::string(size, 'a'));
|
||||
}
|
||||
absl::Cord result = absl::MakeFragmentedCord(chunks);
|
||||
(void) orig_size;
|
||||
assert(result.size() == orig_size);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> Vector(size_t count) {
|
||||
std::vector<T> result;
|
||||
for (size_t v = 0; v < count; ++v) {
|
||||
result.push_back(v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Bogus type that replicates an unorderd_set's bit mixing, but with
|
||||
// vector-speed iteration. This is intended to measure the overhead of unordered
|
||||
// hashing without counting the speed of unordered_set iteration.
|
||||
template <typename T>
|
||||
struct FastUnorderedSet {
|
||||
explicit FastUnorderedSet(size_t count) {
|
||||
for (size_t v = 0; v < count; ++v) {
|
||||
values.push_back(v);
|
||||
}
|
||||
}
|
||||
std::vector<T> values;
|
||||
|
||||
template <typename H>
|
||||
friend H AbslHashValue(H h, const FastUnorderedSet& fus) {
|
||||
return H::combine(H::combine_unordered(std::move(h), fus.values.begin(),
|
||||
fus.values.end()),
|
||||
fus.values.size());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
absl::flat_hash_set<T> FlatHashSet(size_t count) {
|
||||
absl::flat_hash_set<T> result;
|
||||
for (size_t v = 0; v < count; ++v) {
|
||||
result.insert(v);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct LongCombine {
|
||||
T a[200]{};
|
||||
template <typename H>
|
||||
friend H AbslHashValue(H state, const LongCombine& v) {
|
||||
// This is testing a single call to `combine` with a lot of arguments to
|
||||
// test the performance of the folding logic.
|
||||
return H::combine(
|
||||
std::move(state), //
|
||||
v.a[0], v.a[1], v.a[2], v.a[3], v.a[4], v.a[5], v.a[6], v.a[7], v.a[8],
|
||||
v.a[9], v.a[10], v.a[11], v.a[12], v.a[13], v.a[14], v.a[15], v.a[16],
|
||||
v.a[17], v.a[18], v.a[19], v.a[20], v.a[21], v.a[22], v.a[23], v.a[24],
|
||||
v.a[25], v.a[26], v.a[27], v.a[28], v.a[29], v.a[30], v.a[31], v.a[32],
|
||||
v.a[33], v.a[34], v.a[35], v.a[36], v.a[37], v.a[38], v.a[39], v.a[40],
|
||||
v.a[41], v.a[42], v.a[43], v.a[44], v.a[45], v.a[46], v.a[47], v.a[48],
|
||||
v.a[49], v.a[50], v.a[51], v.a[52], v.a[53], v.a[54], v.a[55], v.a[56],
|
||||
v.a[57], v.a[58], v.a[59], v.a[60], v.a[61], v.a[62], v.a[63], v.a[64],
|
||||
v.a[65], v.a[66], v.a[67], v.a[68], v.a[69], v.a[70], v.a[71], v.a[72],
|
||||
v.a[73], v.a[74], v.a[75], v.a[76], v.a[77], v.a[78], v.a[79], v.a[80],
|
||||
v.a[81], v.a[82], v.a[83], v.a[84], v.a[85], v.a[86], v.a[87], v.a[88],
|
||||
v.a[89], v.a[90], v.a[91], v.a[92], v.a[93], v.a[94], v.a[95], v.a[96],
|
||||
v.a[97], v.a[98], v.a[99], v.a[100], v.a[101], v.a[102], v.a[103],
|
||||
v.a[104], v.a[105], v.a[106], v.a[107], v.a[108], v.a[109], v.a[110],
|
||||
v.a[111], v.a[112], v.a[113], v.a[114], v.a[115], v.a[116], v.a[117],
|
||||
v.a[118], v.a[119], v.a[120], v.a[121], v.a[122], v.a[123], v.a[124],
|
||||
v.a[125], v.a[126], v.a[127], v.a[128], v.a[129], v.a[130], v.a[131],
|
||||
v.a[132], v.a[133], v.a[134], v.a[135], v.a[136], v.a[137], v.a[138],
|
||||
v.a[139], v.a[140], v.a[141], v.a[142], v.a[143], v.a[144], v.a[145],
|
||||
v.a[146], v.a[147], v.a[148], v.a[149], v.a[150], v.a[151], v.a[152],
|
||||
v.a[153], v.a[154], v.a[155], v.a[156], v.a[157], v.a[158], v.a[159],
|
||||
v.a[160], v.a[161], v.a[162], v.a[163], v.a[164], v.a[165], v.a[166],
|
||||
v.a[167], v.a[168], v.a[169], v.a[170], v.a[171], v.a[172], v.a[173],
|
||||
v.a[174], v.a[175], v.a[176], v.a[177], v.a[178], v.a[179], v.a[180],
|
||||
v.a[181], v.a[182], v.a[183], v.a[184], v.a[185], v.a[186], v.a[187],
|
||||
v.a[188], v.a[189], v.a[190], v.a[191], v.a[192], v.a[193], v.a[194],
|
||||
v.a[195], v.a[196], v.a[197], v.a[198], v.a[199]);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
auto MakeLongTuple() {
|
||||
auto t1 = std::tuple<T>();
|
||||
auto t2 = std::tuple_cat(t1, t1);
|
||||
auto t3 = std::tuple_cat(t2, t2);
|
||||
auto t4 = std::tuple_cat(t3, t3);
|
||||
auto t5 = std::tuple_cat(t4, t4);
|
||||
auto t6 = std::tuple_cat(t5, t5);
|
||||
// Ideally this would be much larger, but some configurations can't handle
|
||||
// making tuples with that many elements. They break inside std::tuple itself.
|
||||
static_assert(std::tuple_size<decltype(t6)>::value == 32, "");
|
||||
return t6;
|
||||
}
|
||||
|
||||
// Generates a benchmark and a codegen method for the provided types. The
|
||||
// codegen method provides a well known entrypoint for dumping assembly.
|
||||
#define MAKE_BENCHMARK(hash, name, ...) \
|
||||
namespace { \
|
||||
void BM_##hash##_##name(benchmark::State& state) { \
|
||||
RunBenchmark<hash>(state, __VA_ARGS__); \
|
||||
} \
|
||||
BENCHMARK(BM_##hash##_##name); \
|
||||
} \
|
||||
size_t Codegen##hash##name(const decltype(__VA_ARGS__)& arg); \
|
||||
size_t Codegen##hash##name(const decltype(__VA_ARGS__)& arg) { \
|
||||
return hash<decltype(__VA_ARGS__)>{}(arg); \
|
||||
} \
|
||||
bool absl_hash_test_odr_use##hash##name = \
|
||||
(benchmark::DoNotOptimize(&Codegen##hash##name), false)
|
||||
|
||||
MAKE_BENCHMARK(AbslHash, Int32, int32_t{});
|
||||
MAKE_BENCHMARK(AbslHash, Int64, int64_t{});
|
||||
MAKE_BENCHMARK(AbslHash, Double, 1.2);
|
||||
MAKE_BENCHMARK(AbslHash, DoubleZero, 0.0);
|
||||
MAKE_BENCHMARK(AbslHash, PairInt32Int32, std::pair<int32_t, int32_t>{});
|
||||
MAKE_BENCHMARK(AbslHash, PairInt64Int64, std::pair<int64_t, int64_t>{});
|
||||
MAKE_BENCHMARK(AbslHash, TupleInt32BoolInt64,
|
||||
std::tuple<int32_t, bool, int64_t>{});
|
||||
MAKE_BENCHMARK(AbslHash, String_0, std::string());
|
||||
MAKE_BENCHMARK(AbslHash, String_1, std::string(1, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_2, std::string(2, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_4, std::string(4, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_8, std::string(8, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_10, std::string(10, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_30, std::string(30, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_90, std::string(90, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_200, std::string(200, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, String_5000, std::string(5000, 'a'));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_0, absl::Cord());
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_10, FlatCord(10));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_30, FlatCord(30));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_90, FlatCord(90));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_200, FlatCord(200));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Flat_5000, FlatCord(5000));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Fragmented_200, FragmentedCord(200));
|
||||
MAKE_BENCHMARK(AbslHash, Cord_Fragmented_5000, FragmentedCord(5000));
|
||||
MAKE_BENCHMARK(AbslHash, VectorInt64_10, Vector<int64_t>(10));
|
||||
MAKE_BENCHMARK(AbslHash, VectorInt64_100, Vector<int64_t>(100));
|
||||
MAKE_BENCHMARK(AbslHash, VectorInt64_1000, Vector<int64_t>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, VectorDouble_10, Vector<double>(10));
|
||||
MAKE_BENCHMARK(AbslHash, VectorDouble_100, Vector<double>(100));
|
||||
MAKE_BENCHMARK(AbslHash, VectorDouble_1000, Vector<double>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetInt64_10, FlatHashSet<int64_t>(10));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetInt64_100, FlatHashSet<int64_t>(100));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetInt64_1000, FlatHashSet<int64_t>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetDouble_10, FlatHashSet<double>(10));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetDouble_100, FlatHashSet<double>(100));
|
||||
MAKE_BENCHMARK(AbslHash, FlatHashSetDouble_1000, FlatHashSet<double>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, FastUnorderedSetInt64_1000,
|
||||
FastUnorderedSet<int64_t>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, FastUnorderedSetDouble_1000,
|
||||
FastUnorderedSet<double>(1000));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_0,
|
||||
std::make_pair(std::string(), std::string()));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_10,
|
||||
std::make_pair(std::string(10, 'a'), std::string(10, 'b')));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_30,
|
||||
std::make_pair(std::string(30, 'a'), std::string(30, 'b')));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_90,
|
||||
std::make_pair(std::string(90, 'a'), std::string(90, 'b')));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_200,
|
||||
std::make_pair(std::string(200, 'a'), std::string(200, 'b')));
|
||||
MAKE_BENCHMARK(AbslHash, PairStringString_5000,
|
||||
std::make_pair(std::string(5000, 'a'), std::string(5000, 'b')));
|
||||
MAKE_BENCHMARK(AbslHash, LongTupleInt32, MakeLongTuple<int>());
|
||||
MAKE_BENCHMARK(AbslHash, LongTupleString, MakeLongTuple<std::string>());
|
||||
MAKE_BENCHMARK(AbslHash, LongCombineInt32, LongCombine<int>());
|
||||
MAKE_BENCHMARK(AbslHash, LongCombineString, LongCombine<std::string>());
|
||||
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, Int32, int32_t{});
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, Int64, int64_t{});
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, PairInt32Int32,
|
||||
std::pair<int32_t, int32_t>{});
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, PairInt64Int64,
|
||||
std::pair<int64_t, int64_t>{});
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, TupleInt32BoolInt64,
|
||||
std::tuple<int32_t, bool, int64_t>{});
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_0, std::string());
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_10, std::string(10, 'a'));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_30, std::string(30, 'a'));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_90, std::string(90, 'a'));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_200, std::string(200, 'a'));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, String_5000, std::string(5000, 'a'));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, VectorDouble_10,
|
||||
std::vector<double>(10, 1.1));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, VectorDouble_100,
|
||||
std::vector<double>(100, 1.1));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, VectorDouble_1000,
|
||||
std::vector<double>(1000, 1.1));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetInt64_10,
|
||||
FlatHashSet<int64_t>(10));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetInt64_100,
|
||||
FlatHashSet<int64_t>(100));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetInt64_1000,
|
||||
FlatHashSet<int64_t>(1000));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetDouble_10,
|
||||
FlatHashSet<double>(10));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetDouble_100,
|
||||
FlatHashSet<double>(100));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FlatHashSetDouble_1000,
|
||||
FlatHashSet<double>(1000));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FastUnorderedSetInt64_1000,
|
||||
FastUnorderedSet<int64_t>(1000));
|
||||
MAKE_BENCHMARK(TypeErasedAbslHash, FastUnorderedSetDouble_1000,
|
||||
FastUnorderedSet<double>(1000));
|
||||
|
||||
// The latency benchmark attempts to model the speed of the hash function in
|
||||
// production. When a hash function is used for hashtable lookups it is rarely
|
||||
// used to hash N items in a tight loop nor on constant sized strings. Instead,
|
||||
// after hashing there is a potential equality test plus a (usually) large
|
||||
// amount of user code. To simulate this effectively we introduce a data
|
||||
// dependency between elements we hash by using the hash of the Nth element as
|
||||
// the selector of the N+1th element to hash. This isolates the hash function
|
||||
// code much like in production. As a bonus we use the hash to generate strings
|
||||
// of size [1,N] (instead of fixed N) to disable perfect branch predictions in
|
||||
// hash function implementations.
|
||||
namespace {
|
||||
// 16kb fits in L1 cache of most CPUs we care about. Keeping memory latency low
|
||||
// will allow us to attribute most time to CPU which means more accurate
|
||||
// measurements.
|
||||
static constexpr size_t kEntropySize = 16 << 10;
|
||||
static char entropy[kEntropySize + 1024];
|
||||
ABSL_ATTRIBUTE_UNUSED static const bool kInitialized = [] {
|
||||
absl::BitGen gen;
|
||||
static_assert(sizeof(entropy) % sizeof(uint64_t) == 0, "");
|
||||
for (int i = 0; i != sizeof(entropy); i += sizeof(uint64_t)) {
|
||||
auto rand = absl::Uniform<uint64_t>(gen);
|
||||
memcpy(&entropy[i], &rand, sizeof(uint64_t));
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
} // namespace
|
||||
|
||||
template <class T>
|
||||
struct PodRand {
|
||||
static_assert(std::is_pod<T>::value, "");
|
||||
static_assert(kEntropySize + sizeof(T) < sizeof(entropy), "");
|
||||
|
||||
T Get(size_t i) const {
|
||||
T v;
|
||||
memcpy(&v, &entropy[i % kEntropySize], sizeof(T));
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <size_t N>
|
||||
struct StringRand {
|
||||
static_assert(kEntropySize + N < sizeof(entropy), "");
|
||||
|
||||
absl::string_view Get(size_t i) const {
|
||||
// This has a small bias towards small numbers. Because max N is ~200 this
|
||||
// is very small and prefer to be very fast instead of absolutely accurate.
|
||||
// Also we pass N = 2^K+1 so that mod reduces to a bitand.
|
||||
size_t s = (i % (N - 1)) + 1;
|
||||
return {&entropy[i % kEntropySize], s};
|
||||
}
|
||||
};
|
||||
|
||||
#define MAKE_LATENCY_BENCHMARK(hash, name, ...) \
|
||||
namespace { \
|
||||
void BM_latency_##hash##_##name(benchmark::State& state) { \
|
||||
__VA_ARGS__ r; \
|
||||
hash<decltype(r.Get(0))> h; \
|
||||
size_t i = 871401241; \
|
||||
for (auto _ : state) { \
|
||||
benchmark::DoNotOptimize(i = h(r.Get(i))); \
|
||||
} \
|
||||
} \
|
||||
BENCHMARK(BM_latency_##hash##_##name); \
|
||||
} // namespace
|
||||
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, Int32, PodRand<int32_t>)
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, Int64, PodRand<int64_t>)
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, String9, StringRand<9>)
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, String33, StringRand<33>)
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, String65, StringRand<65>)
|
||||
MAKE_LATENCY_BENCHMARK(AbslHash, String257, StringRand<257>)
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This file contains a few select absl::Hash tests that, due to their reliance
|
||||
// on INSTANTIATE_TYPED_TEST_SUITE_P, require a large amount of memory to
|
||||
// compile. Put new tests in hash_test.cc, not this file.
|
||||
|
||||
#include "absl/hash/hash.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <initializer_list>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/container/btree_map.h"
|
||||
#include "absl/container/btree_set.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/container/node_hash_map.h"
|
||||
#include "absl/container/node_hash_set.h"
|
||||
#include "absl/hash/hash_testing.h"
|
||||
#include "absl/hash/internal/hash_test.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using ::absl::hash_test_internal::is_hashable;
|
||||
using ::absl::hash_test_internal::TypeErasedContainer;
|
||||
|
||||
// Dummy type with unordered equality and hashing semantics. This preserves
|
||||
// input order internally, and is used below to ensure we get test coverage
|
||||
// for equal sequences with different iteraton orders.
|
||||
template <typename T>
|
||||
class UnorderedSequence {
|
||||
public:
|
||||
UnorderedSequence() = default;
|
||||
template <typename TT>
|
||||
UnorderedSequence(std::initializer_list<TT> l)
|
||||
: values_(l.begin(), l.end()) {}
|
||||
template <typename ForwardIterator,
|
||||
typename std::enable_if<!std::is_integral<ForwardIterator>::value,
|
||||
bool>::type = true>
|
||||
UnorderedSequence(ForwardIterator begin, ForwardIterator end)
|
||||
: values_(begin, end) {}
|
||||
// one-argument constructor of value type T, to appease older toolchains that
|
||||
// get confused by one-element initializer lists in some contexts
|
||||
explicit UnorderedSequence(const T& v) : values_(&v, &v + 1) {}
|
||||
|
||||
using value_type = T;
|
||||
|
||||
size_t size() const { return values_.size(); }
|
||||
typename std::vector<T>::const_iterator begin() const {
|
||||
return values_.begin();
|
||||
}
|
||||
typename std::vector<T>::const_iterator end() const { return values_.end(); }
|
||||
|
||||
friend bool operator==(const UnorderedSequence& lhs,
|
||||
const UnorderedSequence& rhs) {
|
||||
return lhs.size() == rhs.size() &&
|
||||
std::is_permutation(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
friend bool operator!=(const UnorderedSequence& lhs,
|
||||
const UnorderedSequence& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
template <typename H>
|
||||
friend H AbslHashValue(H h, const UnorderedSequence& u) {
|
||||
return H::combine(H::combine_unordered(std::move(h), u.begin(), u.end()),
|
||||
u.size());
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T> values_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class HashValueSequenceTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(HashValueSequenceTest);
|
||||
|
||||
TYPED_TEST_P(HashValueSequenceTest, BasicUsage) {
|
||||
EXPECT_TRUE((is_hashable<TypeParam>::value));
|
||||
|
||||
using IntType = typename TypeParam::value_type;
|
||||
auto a = static_cast<IntType>(0);
|
||||
auto b = static_cast<IntType>(23);
|
||||
auto c = static_cast<IntType>(42);
|
||||
|
||||
std::vector<TypeParam> exemplars = {
|
||||
TypeParam(), TypeParam(), TypeParam{a, b, c},
|
||||
TypeParam{a, c, b}, TypeParam{c, a, b}, TypeParam{a},
|
||||
TypeParam{a, a}, TypeParam{a, a, a}, TypeParam{a, a, b},
|
||||
TypeParam{a, b, a}, TypeParam{b, a, a}, TypeParam{a, b},
|
||||
TypeParam{b, c}};
|
||||
EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(exemplars));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_SUITE_P(HashValueSequenceTest, BasicUsage);
|
||||
using IntSequenceTypes = testing::Types<
|
||||
std::deque<int>, std::forward_list<int>, std::list<int>, std::vector<int>,
|
||||
std::vector<bool>, TypeErasedContainer<std::vector<int>>, std::set<int>,
|
||||
std::multiset<int>, UnorderedSequence<int>,
|
||||
TypeErasedContainer<UnorderedSequence<int>>, std::unordered_set<int>,
|
||||
std::unordered_multiset<int>, absl::flat_hash_set<int>,
|
||||
absl::node_hash_set<int>, absl::btree_set<int>>;
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(My, HashValueSequenceTest, IntSequenceTypes);
|
||||
|
||||
template <typename T>
|
||||
class HashValueNestedSequenceTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(HashValueNestedSequenceTest);
|
||||
|
||||
TYPED_TEST_P(HashValueNestedSequenceTest, BasicUsage) {
|
||||
using T = TypeParam;
|
||||
using V = typename T::value_type;
|
||||
std::vector<T> exemplars = {
|
||||
// empty case
|
||||
T{},
|
||||
// sets of empty sets
|
||||
T{V{}}, T{V{}, V{}}, T{V{}, V{}, V{}},
|
||||
// multisets of different values
|
||||
T{V{1}}, T{V{1, 1}, V{1, 1}}, T{V{1, 1, 1}, V{1, 1, 1}, V{1, 1, 1}},
|
||||
// various orderings of same nested sets
|
||||
T{V{}, V{1, 2}}, T{V{}, V{2, 1}}, T{V{1, 2}, V{}}, T{V{2, 1}, V{}},
|
||||
// various orderings of various nested sets, case 2
|
||||
T{V{1, 2}, V{3, 4}}, T{V{1, 2}, V{4, 3}}, T{V{1, 3}, V{2, 4}},
|
||||
T{V{1, 3}, V{4, 2}}, T{V{1, 4}, V{2, 3}}, T{V{1, 4}, V{3, 2}},
|
||||
T{V{2, 3}, V{1, 4}}, T{V{2, 3}, V{4, 1}}, T{V{2, 4}, V{1, 3}},
|
||||
T{V{2, 4}, V{3, 1}}, T{V{3, 4}, V{1, 2}}, T{V{3, 4}, V{2, 1}}};
|
||||
EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(exemplars));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_SUITE_P(HashValueNestedSequenceTest, BasicUsage);
|
||||
template <typename T>
|
||||
using TypeErasedSet = TypeErasedContainer<UnorderedSequence<T>>;
|
||||
|
||||
using NestedIntSequenceTypes = testing::Types<
|
||||
std::vector<std::vector<int>>, std::vector<UnorderedSequence<int>>,
|
||||
std::vector<TypeErasedSet<int>>, UnorderedSequence<std::vector<int>>,
|
||||
UnorderedSequence<UnorderedSequence<int>>,
|
||||
UnorderedSequence<TypeErasedSet<int>>, TypeErasedSet<std::vector<int>>,
|
||||
TypeErasedSet<UnorderedSequence<int>>, TypeErasedSet<TypeErasedSet<int>>>;
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(My, HashValueNestedSequenceTest,
|
||||
NestedIntSequenceTypes);
|
||||
|
||||
template <typename T>
|
||||
class HashValueAssociativeMapTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(HashValueAssociativeMapTest);
|
||||
|
||||
TYPED_TEST_P(HashValueAssociativeMapTest, BasicUsage) {
|
||||
using M = TypeParam;
|
||||
using V = typename M::value_type;
|
||||
std::vector<M> exemplars{M{},
|
||||
M{V{0, "foo"}},
|
||||
M{V{1, "foo"}},
|
||||
M{V{0, "bar"}},
|
||||
M{V{1, "bar"}},
|
||||
M{V{0, "foo"}, V{42, "bar"}},
|
||||
M{V{42, "bar"}, V{0, "foo"}},
|
||||
M{V{1, "foo"}, V{42, "bar"}},
|
||||
M{V{1, "foo"}, V{43, "bar"}},
|
||||
M{V{1, "foo"}, V{43, "baz"}}};
|
||||
EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(exemplars));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_SUITE_P(HashValueAssociativeMapTest, BasicUsage);
|
||||
using AssociativeMapTypes = testing::Types<
|
||||
std::map<int, std::string>, std::unordered_map<int, std::string>,
|
||||
absl::flat_hash_map<int, std::string>,
|
||||
absl::node_hash_map<int, std::string>, absl::btree_map<int, std::string>,
|
||||
UnorderedSequence<std::pair<const int, std::string>>>;
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(My, HashValueAssociativeMapTest,
|
||||
AssociativeMapTypes);
|
||||
|
||||
template <typename T>
|
||||
class HashValueAssociativeMultimapTest : public testing::Test {};
|
||||
TYPED_TEST_SUITE_P(HashValueAssociativeMultimapTest);
|
||||
|
||||
TYPED_TEST_P(HashValueAssociativeMultimapTest, BasicUsage) {
|
||||
using MM = TypeParam;
|
||||
using V = typename MM::value_type;
|
||||
std::vector<MM> exemplars{MM{},
|
||||
MM{V{0, "foo"}},
|
||||
MM{V{1, "foo"}},
|
||||
MM{V{0, "bar"}},
|
||||
MM{V{1, "bar"}},
|
||||
MM{V{0, "foo"}, V{0, "bar"}},
|
||||
MM{V{0, "bar"}, V{0, "foo"}},
|
||||
MM{V{0, "foo"}, V{42, "bar"}},
|
||||
MM{V{1, "foo"}, V{42, "bar"}},
|
||||
MM{V{1, "foo"}, V{1, "foo"}, V{43, "bar"}},
|
||||
MM{V{1, "foo"}, V{43, "bar"}, V{1, "foo"}},
|
||||
MM{V{1, "foo"}, V{43, "baz"}}};
|
||||
EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(exemplars));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_SUITE_P(HashValueAssociativeMultimapTest, BasicUsage);
|
||||
using AssociativeMultimapTypes =
|
||||
testing::Types<std::multimap<int, std::string>,
|
||||
std::unordered_multimap<int, std::string>>;
|
||||
INSTANTIATE_TYPED_TEST_SUITE_P(My, HashValueAssociativeMultimapTest,
|
||||
AssociativeMultimapTypes);
|
||||
|
||||
} // namespace
|
||||
1216
TMessagesProj/jni/voip/webrtc/absl/hash/hash_test.cc
Normal file
1216
TMessagesProj/jni/voip/webrtc/absl/hash/hash_test.cc
Normal file
File diff suppressed because it is too large
Load diff
380
TMessagesProj/jni/voip/webrtc/absl/hash/hash_testing.h
Normal file
380
TMessagesProj/jni/voip/webrtc/absl/hash/hash_testing.h
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ABSL_HASH_HASH_TESTING_H_
|
||||
#define ABSL_HASH_HASH_TESTING_H_
|
||||
|
||||
#include <initializer_list>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/hash/internal/spy_hash_state.h"
|
||||
#include "absl/meta/type_traits.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/types/variant.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
|
||||
// Run the absl::Hash algorithm over all the elements passed in and verify that
|
||||
// their hash expansion is congruent with their `==` operator.
|
||||
//
|
||||
// It is used in conjunction with EXPECT_TRUE. Failures will output information
|
||||
// on what requirement failed and on which objects.
|
||||
//
|
||||
// Users should pass a collection of types as either an initializer list or a
|
||||
// container of cases.
|
||||
//
|
||||
// EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(
|
||||
// {v1, v2, ..., vN}));
|
||||
//
|
||||
// std::vector<MyType> cases;
|
||||
// // Fill cases...
|
||||
// EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(cases));
|
||||
//
|
||||
// Users can pass a variety of types for testing heterogeneous lookup with
|
||||
// `std::make_tuple`:
|
||||
//
|
||||
// EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(
|
||||
// std::make_tuple(v1, v2, ..., vN)));
|
||||
//
|
||||
//
|
||||
// Ideally, the values passed should provide enough coverage of the `==`
|
||||
// operator and the AbslHashValue implementations.
|
||||
// For dynamically sized types, the empty state should usually be included in
|
||||
// the values.
|
||||
//
|
||||
// The function accepts an optional comparator function, in case that `==` is
|
||||
// not enough for the values provided.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(
|
||||
// std::make_tuple(v1, v2, ..., vN), MyCustomEq{}));
|
||||
//
|
||||
// It checks the following requirements:
|
||||
// 1. The expansion for a value is deterministic.
|
||||
// 2. For any two objects `a` and `b` in the sequence, if `a == b` evaluates
|
||||
// to true, then their hash expansion must be equal.
|
||||
// 3. If `a == b` evaluates to false their hash expansion must be unequal.
|
||||
// 4. If `a == b` evaluates to false neither hash expansion can be a
|
||||
// suffix of the other.
|
||||
// 5. AbslHashValue overloads should not be called by the user. They are only
|
||||
// meant to be called by the framework. Users should call H::combine() and
|
||||
// H::combine_contiguous().
|
||||
// 6. No moved-from instance of the hash state is used in the implementation
|
||||
// of AbslHashValue.
|
||||
//
|
||||
// The values do not have to have the same type. This can be useful for
|
||||
// equivalent types that support heterogeneous lookup.
|
||||
//
|
||||
// A possible reason for breaking (2) is combining state in the hash expansion
|
||||
// that was not used in `==`.
|
||||
// For example:
|
||||
//
|
||||
// struct Bad2 {
|
||||
// int a, b;
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H state, Bad2 x) {
|
||||
// // Uses a and b.
|
||||
// return H::combine(std::move(state), x.a, x.b);
|
||||
// }
|
||||
// friend bool operator==(Bad2 x, Bad2 y) {
|
||||
// // Only uses a.
|
||||
// return x.a == y.a;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// As for (3), breaking this usually means that there is state being passed to
|
||||
// the `==` operator that is not used in the hash expansion.
|
||||
// For example:
|
||||
//
|
||||
// struct Bad3 {
|
||||
// int a, b;
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H state, Bad3 x) {
|
||||
// // Only uses a.
|
||||
// return H::combine(std::move(state), x.a);
|
||||
// }
|
||||
// friend bool operator==(Bad3 x, Bad3 y) {
|
||||
// // Uses a and b.
|
||||
// return x.a == y.a && x.b == y.b;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// Finally, a common way to break 4 is by combining dynamic ranges without
|
||||
// combining the size of the range.
|
||||
// For example:
|
||||
//
|
||||
// struct Bad4 {
|
||||
// int *p, size;
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H state, Bad4 x) {
|
||||
// return H::combine_contiguous(std::move(state), x.p, x.p + x.size);
|
||||
// }
|
||||
// friend bool operator==(Bad4 x, Bad4 y) {
|
||||
// // Compare two ranges for equality. C++14 code can instead use std::equal.
|
||||
// return absl::equal(x.p, x.p + x.size, y.p, y.p + y.size);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// An easy solution to this is to combine the size after combining the range,
|
||||
// like so:
|
||||
// template <typename H>
|
||||
// friend H AbslHashValue(H state, Bad4 x) {
|
||||
// return H::combine(
|
||||
// H::combine_contiguous(std::move(state), x.p, x.p + x.size), x.size);
|
||||
// }
|
||||
//
|
||||
template <int&... ExplicitBarrier, typename Container>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(const Container& values);
|
||||
|
||||
template <int&... ExplicitBarrier, typename Container, typename Eq>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(const Container& values, Eq equals);
|
||||
|
||||
template <int&..., typename T>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(std::initializer_list<T> values);
|
||||
|
||||
template <int&..., typename T, typename Eq>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(std::initializer_list<T> values,
|
||||
Eq equals);
|
||||
|
||||
namespace hash_internal {
|
||||
|
||||
struct PrintVisitor {
|
||||
size_t index;
|
||||
template <typename T>
|
||||
std::string operator()(const T* value) const {
|
||||
return absl::StrCat("#", index, "(", testing::PrintToString(*value), ")");
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Eq>
|
||||
struct EqVisitor {
|
||||
Eq eq;
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T* t, const U* u) const {
|
||||
return eq(*t, *u);
|
||||
}
|
||||
};
|
||||
|
||||
struct ExpandVisitor {
|
||||
template <typename T>
|
||||
SpyHashState operator()(const T* value) const {
|
||||
return SpyHashState::combine(SpyHashState(), *value);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Container, typename Eq>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(const Container& values, Eq equals) {
|
||||
using V = typename Container::value_type;
|
||||
|
||||
struct Info {
|
||||
const V& value;
|
||||
size_t index;
|
||||
std::string ToString() const {
|
||||
return absl::visit(PrintVisitor{index}, value);
|
||||
}
|
||||
SpyHashState expand() const { return absl::visit(ExpandVisitor{}, value); }
|
||||
};
|
||||
|
||||
using EqClass = std::vector<Info>;
|
||||
std::vector<EqClass> classes;
|
||||
|
||||
// Gather the values in equivalence classes.
|
||||
size_t i = 0;
|
||||
for (const auto& value : values) {
|
||||
EqClass* c = nullptr;
|
||||
for (auto& eqclass : classes) {
|
||||
if (absl::visit(EqVisitor<Eq>{equals}, value, eqclass[0].value)) {
|
||||
c = &eqclass;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (c == nullptr) {
|
||||
classes.emplace_back();
|
||||
c = &classes.back();
|
||||
}
|
||||
c->push_back({value, i});
|
||||
++i;
|
||||
|
||||
// Verify potential errors captured by SpyHashState.
|
||||
if (auto error = c->back().expand().error()) {
|
||||
return testing::AssertionFailure() << *error;
|
||||
}
|
||||
}
|
||||
|
||||
if (classes.size() < 2) {
|
||||
return testing::AssertionFailure()
|
||||
<< "At least two equivalence classes are expected.";
|
||||
}
|
||||
|
||||
// We assume that equality is correctly implemented.
|
||||
// Now we verify that AbslHashValue is also correctly implemented.
|
||||
|
||||
for (const auto& c : classes) {
|
||||
// All elements of the equivalence class must have the same hash
|
||||
// expansion.
|
||||
const SpyHashState expected = c[0].expand();
|
||||
for (const Info& v : c) {
|
||||
if (v.expand() != v.expand()) {
|
||||
return testing::AssertionFailure()
|
||||
<< "Hash expansion for " << v.ToString()
|
||||
<< " is non-deterministic.";
|
||||
}
|
||||
if (v.expand() != expected) {
|
||||
return testing::AssertionFailure()
|
||||
<< "Values " << c[0].ToString() << " and " << v.ToString()
|
||||
<< " evaluate as equal but have unequal hash expansions ("
|
||||
<< expected << " vs. " << v.expand() << ").";
|
||||
}
|
||||
}
|
||||
|
||||
// Elements from other classes must have different hash expansion.
|
||||
for (const auto& c2 : classes) {
|
||||
if (&c == &c2) continue;
|
||||
const SpyHashState c2_hash = c2[0].expand();
|
||||
switch (SpyHashState::Compare(expected, c2_hash)) {
|
||||
case SpyHashState::CompareResult::kEqual:
|
||||
return testing::AssertionFailure()
|
||||
<< "Values " << c[0].ToString() << " and " << c2[0].ToString()
|
||||
<< " evaluate as unequal but have an equal hash expansion:"
|
||||
<< c2_hash << ".";
|
||||
case SpyHashState::CompareResult::kBSuffixA:
|
||||
return testing::AssertionFailure()
|
||||
<< "Hash expansion of " << c2[0].ToString() << ";" << c2_hash
|
||||
<< " is a suffix of the hash expansion of " << c[0].ToString()
|
||||
<< ";" << expected << ".";
|
||||
case SpyHashState::CompareResult::kASuffixB:
|
||||
return testing::AssertionFailure()
|
||||
<< "Hash expansion of " << c[0].ToString() << ";"
|
||||
<< expected << " is a suffix of the hash expansion of "
|
||||
<< c2[0].ToString() << ";" << c2_hash << ".";
|
||||
case SpyHashState::CompareResult::kUnequal:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
struct TypeSet {
|
||||
template <typename U, bool = disjunction<std::is_same<T, U>...>::value>
|
||||
struct Insert {
|
||||
using type = TypeSet<U, T...>;
|
||||
};
|
||||
template <typename U>
|
||||
struct Insert<U, true> {
|
||||
using type = TypeSet;
|
||||
};
|
||||
|
||||
template <template <typename...> class C>
|
||||
using apply = C<T...>;
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
struct MakeTypeSet : TypeSet<> {};
|
||||
template <typename T, typename... Ts>
|
||||
struct MakeTypeSet<T, Ts...> : MakeTypeSet<Ts...>::template Insert<T>::type {};
|
||||
|
||||
template <typename... T>
|
||||
using VariantForTypes = typename MakeTypeSet<
|
||||
const typename std::decay<T>::type*...>::template apply<absl::variant>;
|
||||
|
||||
template <typename Container>
|
||||
struct ContainerAsVector {
|
||||
using V = absl::variant<const typename Container::value_type*>;
|
||||
using Out = std::vector<V>;
|
||||
|
||||
static Out Do(const Container& values) {
|
||||
Out out;
|
||||
for (const auto& v : values) out.push_back(&v);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
struct ContainerAsVector<std::tuple<T...>> {
|
||||
using V = VariantForTypes<T...>;
|
||||
using Out = std::vector<V>;
|
||||
|
||||
template <size_t... I>
|
||||
static Out DoImpl(const std::tuple<T...>& tuple, absl::index_sequence<I...>) {
|
||||
return Out{&std::get<I>(tuple)...};
|
||||
}
|
||||
|
||||
static Out Do(const std::tuple<T...>& values) {
|
||||
return DoImpl(values, absl::index_sequence_for<T...>());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ContainerAsVector<std::tuple<>> {
|
||||
static std::vector<VariantForTypes<int>> Do(std::tuple<>) { return {}; }
|
||||
};
|
||||
|
||||
struct DefaultEquals {
|
||||
template <typename T, typename U>
|
||||
bool operator()(const T& t, const U& u) const {
|
||||
return t == u;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace hash_internal
|
||||
|
||||
template <int&..., typename Container>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(const Container& values) {
|
||||
return hash_internal::VerifyTypeImplementsAbslHashCorrectly(
|
||||
hash_internal::ContainerAsVector<Container>::Do(values),
|
||||
hash_internal::DefaultEquals{});
|
||||
}
|
||||
|
||||
template <int&..., typename Container, typename Eq>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(const Container& values, Eq equals) {
|
||||
return hash_internal::VerifyTypeImplementsAbslHashCorrectly(
|
||||
hash_internal::ContainerAsVector<Container>::Do(values), equals);
|
||||
}
|
||||
|
||||
template <int&..., typename T>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(std::initializer_list<T> values) {
|
||||
return hash_internal::VerifyTypeImplementsAbslHashCorrectly(
|
||||
hash_internal::ContainerAsVector<std::initializer_list<T>>::Do(values),
|
||||
hash_internal::DefaultEquals{});
|
||||
}
|
||||
|
||||
template <int&..., typename T, typename Eq>
|
||||
ABSL_MUST_USE_RESULT testing::AssertionResult
|
||||
VerifyTypeImplementsAbslHashCorrectly(std::initializer_list<T> values,
|
||||
Eq equals) {
|
||||
return hash_internal::VerifyTypeImplementsAbslHashCorrectly(
|
||||
hash_internal::ContainerAsVector<std::initializer_list<T>>::Do(values),
|
||||
equals);
|
||||
}
|
||||
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_HASH_TESTING_H_
|
||||
349
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city.cc
Normal file
349
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city.cc
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file provides CityHash64() and related functions.
|
||||
//
|
||||
// It's probably possible to create even faster hash functions by
|
||||
// writing a program that systematically explores some of the space of
|
||||
// possible hash functions, by using SIMD instructions, or by
|
||||
// compromising on hash quality.
|
||||
|
||||
#include "absl/hash/internal/city.h"
|
||||
|
||||
#include <string.h> // for memcpy and memset
|
||||
#include <algorithm>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/base/internal/endian.h"
|
||||
#include "absl/base/internal/unaligned_access.h"
|
||||
#include "absl/base/optimization.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
#ifdef ABSL_IS_BIG_ENDIAN
|
||||
#define uint32_in_expected_order(x) (absl::gbswap_32(x))
|
||||
#define uint64_in_expected_order(x) (absl::gbswap_64(x))
|
||||
#else
|
||||
#define uint32_in_expected_order(x) (x)
|
||||
#define uint64_in_expected_order(x) (x)
|
||||
#endif
|
||||
|
||||
static uint64_t Fetch64(const char *p) {
|
||||
return uint64_in_expected_order(ABSL_INTERNAL_UNALIGNED_LOAD64(p));
|
||||
}
|
||||
|
||||
static uint32_t Fetch32(const char *p) {
|
||||
return uint32_in_expected_order(ABSL_INTERNAL_UNALIGNED_LOAD32(p));
|
||||
}
|
||||
|
||||
// Some primes between 2^63 and 2^64 for various uses.
|
||||
static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
|
||||
static const uint64_t k1 = 0xb492b66fbe98f273ULL;
|
||||
static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
|
||||
|
||||
// Magic numbers for 32-bit hashing. Copied from Murmur3.
|
||||
static const uint32_t c1 = 0xcc9e2d51;
|
||||
static const uint32_t c2 = 0x1b873593;
|
||||
|
||||
// A 32-bit to 32-bit integer hash copied from Murmur3.
|
||||
static uint32_t fmix(uint32_t h) {
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
h *= 0xc2b2ae35;
|
||||
h ^= h >> 16;
|
||||
return h;
|
||||
}
|
||||
|
||||
static uint32_t Rotate32(uint32_t val, int shift) {
|
||||
// Avoid shifting by 32: doing so yields an undefined result.
|
||||
return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
|
||||
}
|
||||
|
||||
#undef PERMUTE3
|
||||
#define PERMUTE3(a, b, c) \
|
||||
do { \
|
||||
std::swap(a, b); \
|
||||
std::swap(a, c); \
|
||||
} while (0)
|
||||
|
||||
static uint32_t Mur(uint32_t a, uint32_t h) {
|
||||
// Helper from Murmur3 for combining two 32-bit values.
|
||||
a *= c1;
|
||||
a = Rotate32(a, 17);
|
||||
a *= c2;
|
||||
h ^= a;
|
||||
h = Rotate32(h, 19);
|
||||
return h * 5 + 0xe6546b64;
|
||||
}
|
||||
|
||||
static uint32_t Hash32Len13to24(const char *s, size_t len) {
|
||||
uint32_t a = Fetch32(s - 4 + (len >> 1));
|
||||
uint32_t b = Fetch32(s + 4);
|
||||
uint32_t c = Fetch32(s + len - 8);
|
||||
uint32_t d = Fetch32(s + (len >> 1));
|
||||
uint32_t e = Fetch32(s);
|
||||
uint32_t f = Fetch32(s + len - 4);
|
||||
uint32_t h = static_cast<uint32_t>(len);
|
||||
|
||||
return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
|
||||
}
|
||||
|
||||
static uint32_t Hash32Len0to4(const char *s, size_t len) {
|
||||
uint32_t b = 0;
|
||||
uint32_t c = 9;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
signed char v = static_cast<signed char>(s[i]);
|
||||
b = b * c1 + static_cast<uint32_t>(v);
|
||||
c ^= b;
|
||||
}
|
||||
return fmix(Mur(b, Mur(static_cast<uint32_t>(len), c)));
|
||||
}
|
||||
|
||||
static uint32_t Hash32Len5to12(const char *s, size_t len) {
|
||||
uint32_t a = static_cast<uint32_t>(len), b = a * 5, c = 9, d = b;
|
||||
a += Fetch32(s);
|
||||
b += Fetch32(s + len - 4);
|
||||
c += Fetch32(s + ((len >> 1) & 4));
|
||||
return fmix(Mur(c, Mur(b, Mur(a, d))));
|
||||
}
|
||||
|
||||
uint32_t CityHash32(const char *s, size_t len) {
|
||||
if (len <= 24) {
|
||||
return len <= 12
|
||||
? (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len))
|
||||
: Hash32Len13to24(s, len);
|
||||
}
|
||||
|
||||
// len > 24
|
||||
uint32_t h = static_cast<uint32_t>(len), g = c1 * h, f = g;
|
||||
|
||||
uint32_t a0 = Rotate32(Fetch32(s + len - 4) * c1, 17) * c2;
|
||||
uint32_t a1 = Rotate32(Fetch32(s + len - 8) * c1, 17) * c2;
|
||||
uint32_t a2 = Rotate32(Fetch32(s + len - 16) * c1, 17) * c2;
|
||||
uint32_t a3 = Rotate32(Fetch32(s + len - 12) * c1, 17) * c2;
|
||||
uint32_t a4 = Rotate32(Fetch32(s + len - 20) * c1, 17) * c2;
|
||||
h ^= a0;
|
||||
h = Rotate32(h, 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
h ^= a2;
|
||||
h = Rotate32(h, 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
g ^= a1;
|
||||
g = Rotate32(g, 19);
|
||||
g = g * 5 + 0xe6546b64;
|
||||
g ^= a3;
|
||||
g = Rotate32(g, 19);
|
||||
g = g * 5 + 0xe6546b64;
|
||||
f += a4;
|
||||
f = Rotate32(f, 19);
|
||||
f = f * 5 + 0xe6546b64;
|
||||
size_t iters = (len - 1) / 20;
|
||||
do {
|
||||
uint32_t b0 = Rotate32(Fetch32(s) * c1, 17) * c2;
|
||||
uint32_t b1 = Fetch32(s + 4);
|
||||
uint32_t b2 = Rotate32(Fetch32(s + 8) * c1, 17) * c2;
|
||||
uint32_t b3 = Rotate32(Fetch32(s + 12) * c1, 17) * c2;
|
||||
uint32_t b4 = Fetch32(s + 16);
|
||||
h ^= b0;
|
||||
h = Rotate32(h, 18);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
f += b1;
|
||||
f = Rotate32(f, 19);
|
||||
f = f * c1;
|
||||
g += b2;
|
||||
g = Rotate32(g, 18);
|
||||
g = g * 5 + 0xe6546b64;
|
||||
h ^= b3 + b1;
|
||||
h = Rotate32(h, 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
g ^= b4;
|
||||
g = absl::gbswap_32(g) * 5;
|
||||
h += b4 * 5;
|
||||
h = absl::gbswap_32(h);
|
||||
f += b0;
|
||||
PERMUTE3(f, h, g);
|
||||
s += 20;
|
||||
} while (--iters != 0);
|
||||
g = Rotate32(g, 11) * c1;
|
||||
g = Rotate32(g, 17) * c1;
|
||||
f = Rotate32(f, 11) * c1;
|
||||
f = Rotate32(f, 17) * c1;
|
||||
h = Rotate32(h + g, 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
h = Rotate32(h, 17) * c1;
|
||||
h = Rotate32(h + f, 19);
|
||||
h = h * 5 + 0xe6546b64;
|
||||
h = Rotate32(h, 17) * c1;
|
||||
return h;
|
||||
}
|
||||
|
||||
// Bitwise right rotate. Normally this will compile to a single
|
||||
// instruction, especially if the shift is a manifest constant.
|
||||
static uint64_t Rotate(uint64_t val, int shift) {
|
||||
// Avoid shifting by 64: doing so yields an undefined result.
|
||||
return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
|
||||
}
|
||||
|
||||
static uint64_t ShiftMix(uint64_t val) { return val ^ (val >> 47); }
|
||||
|
||||
static uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
|
||||
// Murmur-inspired hashing.
|
||||
uint64_t a = (u ^ v) * mul;
|
||||
a ^= (a >> 47);
|
||||
uint64_t b = (v ^ a) * mul;
|
||||
b ^= (b >> 47);
|
||||
b *= mul;
|
||||
return b;
|
||||
}
|
||||
|
||||
static uint64_t HashLen16(uint64_t u, uint64_t v) {
|
||||
const uint64_t kMul = 0x9ddfea08eb382d69ULL;
|
||||
return HashLen16(u, v, kMul);
|
||||
}
|
||||
|
||||
static uint64_t HashLen0to16(const char *s, size_t len) {
|
||||
if (len >= 8) {
|
||||
uint64_t mul = k2 + len * 2;
|
||||
uint64_t a = Fetch64(s) + k2;
|
||||
uint64_t b = Fetch64(s + len - 8);
|
||||
uint64_t c = Rotate(b, 37) * mul + a;
|
||||
uint64_t d = (Rotate(a, 25) + b) * mul;
|
||||
return HashLen16(c, d, mul);
|
||||
}
|
||||
if (len >= 4) {
|
||||
uint64_t mul = k2 + len * 2;
|
||||
uint64_t a = Fetch32(s);
|
||||
return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
|
||||
}
|
||||
if (len > 0) {
|
||||
uint8_t a = static_cast<uint8_t>(s[0]);
|
||||
uint8_t b = static_cast<uint8_t>(s[len >> 1]);
|
||||
uint8_t c = static_cast<uint8_t>(s[len - 1]);
|
||||
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
|
||||
uint32_t z = static_cast<uint32_t>(len) + (static_cast<uint32_t>(c) << 2);
|
||||
return ShiftMix(y * k2 ^ z * k0) * k2;
|
||||
}
|
||||
return k2;
|
||||
}
|
||||
|
||||
// This probably works well for 16-byte strings as well, but it may be overkill
|
||||
// in that case.
|
||||
static uint64_t HashLen17to32(const char *s, size_t len) {
|
||||
uint64_t mul = k2 + len * 2;
|
||||
uint64_t a = Fetch64(s) * k1;
|
||||
uint64_t b = Fetch64(s + 8);
|
||||
uint64_t c = Fetch64(s + len - 8) * mul;
|
||||
uint64_t d = Fetch64(s + len - 16) * k2;
|
||||
return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
|
||||
a + Rotate(b + k2, 18) + c, mul);
|
||||
}
|
||||
|
||||
// Return a 16-byte hash for 48 bytes. Quick and dirty.
|
||||
// Callers do best to use "random-looking" values for a and b.
|
||||
static std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
|
||||
uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
|
||||
a += w;
|
||||
b = Rotate(b + a + z, 21);
|
||||
uint64_t c = a;
|
||||
a += x;
|
||||
a += y;
|
||||
b += Rotate(a, 44);
|
||||
return std::make_pair(a + z, b + c);
|
||||
}
|
||||
|
||||
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
|
||||
static std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(const char *s,
|
||||
uint64_t a,
|
||||
uint64_t b) {
|
||||
return WeakHashLen32WithSeeds(Fetch64(s), Fetch64(s + 8), Fetch64(s + 16),
|
||||
Fetch64(s + 24), a, b);
|
||||
}
|
||||
|
||||
// Return an 8-byte hash for 33 to 64 bytes.
|
||||
static uint64_t HashLen33to64(const char *s, size_t len) {
|
||||
uint64_t mul = k2 + len * 2;
|
||||
uint64_t a = Fetch64(s) * k2;
|
||||
uint64_t b = Fetch64(s + 8);
|
||||
uint64_t c = Fetch64(s + len - 24);
|
||||
uint64_t d = Fetch64(s + len - 32);
|
||||
uint64_t e = Fetch64(s + 16) * k2;
|
||||
uint64_t f = Fetch64(s + 24) * 9;
|
||||
uint64_t g = Fetch64(s + len - 8);
|
||||
uint64_t h = Fetch64(s + len - 16) * mul;
|
||||
uint64_t u = Rotate(a + g, 43) + (Rotate(b, 30) + c) * 9;
|
||||
uint64_t v = ((a + g) ^ d) + f + 1;
|
||||
uint64_t w = absl::gbswap_64((u + v) * mul) + h;
|
||||
uint64_t x = Rotate(e + f, 42) + c;
|
||||
uint64_t y = (absl::gbswap_64((v + w) * mul) + g) * mul;
|
||||
uint64_t z = e + f + c;
|
||||
a = absl::gbswap_64((x + z) * mul + y) + b;
|
||||
b = ShiftMix((z + a) * mul + d + h) * mul;
|
||||
return b + x;
|
||||
}
|
||||
|
||||
uint64_t CityHash64(const char *s, size_t len) {
|
||||
if (len <= 32) {
|
||||
if (len <= 16) {
|
||||
return HashLen0to16(s, len);
|
||||
} else {
|
||||
return HashLen17to32(s, len);
|
||||
}
|
||||
} else if (len <= 64) {
|
||||
return HashLen33to64(s, len);
|
||||
}
|
||||
|
||||
// For strings over 64 bytes we hash the end first, and then as we
|
||||
// loop we keep 56 bytes of state: v, w, x, y, and z.
|
||||
uint64_t x = Fetch64(s + len - 40);
|
||||
uint64_t y = Fetch64(s + len - 16) + Fetch64(s + len - 56);
|
||||
uint64_t z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24));
|
||||
std::pair<uint64_t, uint64_t> v =
|
||||
WeakHashLen32WithSeeds(s + len - 64, len, z);
|
||||
std::pair<uint64_t, uint64_t> w =
|
||||
WeakHashLen32WithSeeds(s + len - 32, y + k1, x);
|
||||
x = x * k1 + Fetch64(s);
|
||||
|
||||
// Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
|
||||
len = (len - 1) & ~static_cast<size_t>(63);
|
||||
do {
|
||||
x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
|
||||
y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
|
||||
x ^= w.second;
|
||||
y += v.first + Fetch64(s + 40);
|
||||
z = Rotate(z + w.first, 33) * k1;
|
||||
v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
|
||||
w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
|
||||
std::swap(z, x);
|
||||
s += 64;
|
||||
len -= 64;
|
||||
} while (len != 0);
|
||||
return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
|
||||
HashLen16(v.second, w.second) + x);
|
||||
}
|
||||
|
||||
uint64_t CityHash64WithSeed(const char *s, size_t len, uint64_t seed) {
|
||||
return CityHash64WithSeeds(s, len, k2, seed);
|
||||
}
|
||||
|
||||
uint64_t CityHash64WithSeeds(const char *s, size_t len, uint64_t seed0,
|
||||
uint64_t seed1) {
|
||||
return HashLen16(CityHash64(s, len) - seed0, seed1);
|
||||
}
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
78
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city.h
Normal file
78
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// https://code.google.com/p/cityhash/
|
||||
//
|
||||
// This file provides a few functions for hashing strings. All of them are
|
||||
// high-quality functions in the sense that they pass standard tests such
|
||||
// as Austin Appleby's SMHasher. They are also fast.
|
||||
//
|
||||
// For 64-bit x86 code, on short strings, we don't know of anything faster than
|
||||
// CityHash64 that is of comparable quality. We believe our nearest competitor
|
||||
// is Murmur3. For 64-bit x86 code, CityHash64 is an excellent choice for hash
|
||||
// tables and most other hashing (excluding cryptography).
|
||||
//
|
||||
// For 32-bit x86 code, we don't know of anything faster than CityHash32 that
|
||||
// is of comparable quality. We believe our nearest competitor is Murmur3A.
|
||||
// (On 64-bit CPUs, it is typically faster to use the other CityHash variants.)
|
||||
//
|
||||
// Functions in the CityHash family are not suitable for cryptography.
|
||||
//
|
||||
// Please see CityHash's README file for more details on our performance
|
||||
// measurements and so on.
|
||||
//
|
||||
// WARNING: This code has been only lightly tested on big-endian platforms!
|
||||
// It is known to work well on little-endian platforms that have a small penalty
|
||||
// for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
|
||||
// It should work on all 32-bit and 64-bit platforms that allow unaligned reads;
|
||||
// bug reports are welcome.
|
||||
//
|
||||
// By the way, for some hash functions, given strings a and b, the hash
|
||||
// of a+b is easily derived from the hashes of a and b. This property
|
||||
// doesn't hold for any hash functions in this file.
|
||||
|
||||
#ifndef ABSL_HASH_INTERNAL_CITY_H_
|
||||
#define ABSL_HASH_INTERNAL_CITY_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h> // for size_t.
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
// Hash function for a byte array.
|
||||
uint64_t CityHash64(const char *s, size_t len);
|
||||
|
||||
// Hash function for a byte array. For convenience, a 64-bit seed is also
|
||||
// hashed into the result.
|
||||
uint64_t CityHash64WithSeed(const char *s, size_t len, uint64_t seed);
|
||||
|
||||
// Hash function for a byte array. For convenience, two seeds are also
|
||||
// hashed into the result.
|
||||
uint64_t CityHash64WithSeeds(const char *s, size_t len, uint64_t seed0,
|
||||
uint64_t seed1);
|
||||
|
||||
// Hash function for a byte array. Most useful in 32-bit binaries.
|
||||
uint32_t CityHash32(const char *s, size_t len);
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_INTERNAL_CITY_H_
|
||||
597
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city_test.cc
Normal file
597
TMessagesProj/jni/voip/webrtc/absl/hash/internal/city_test.cc
Normal file
|
|
@ -0,0 +1,597 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/hash/internal/city.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
namespace {
|
||||
|
||||
static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
|
||||
static const uint64_t kSeed0 = 1234567;
|
||||
static const uint64_t kSeed1 = k0;
|
||||
static const int kDataSize = 1 << 20;
|
||||
static const int kTestSize = 300;
|
||||
|
||||
static char data[kDataSize];
|
||||
|
||||
// Initialize data to pseudorandom values.
|
||||
void setup() {
|
||||
uint64_t a = 9;
|
||||
uint64_t b = 777;
|
||||
for (int i = 0; i < kDataSize; i++) {
|
||||
a += b;
|
||||
b += a;
|
||||
a = (a ^ (a >> 41)) * k0;
|
||||
b = (b ^ (b >> 41)) * k0 + i;
|
||||
uint8_t u = b >> 37;
|
||||
memcpy(data + i, &u, 1); // uint8_t -> char
|
||||
}
|
||||
}
|
||||
|
||||
#define C(x) 0x##x##ULL
|
||||
static const uint64_t testdata[kTestSize][4] = {
|
||||
{C(9ae16a3b2f90404f), C(75106db890237a4a), C(3feac5f636039766),
|
||||
C(dc56d17a)},
|
||||
{C(541150e87f415e96), C(1aef0d24b3148a1a), C(bacc300e1e82345a),
|
||||
C(99929334)},
|
||||
{C(f3786a4b25827c1), C(34ee1a2bf767bd1c), C(2f15ca2ebfb631f2), C(4252edb7)},
|
||||
{C(ef923a7a1af78eab), C(79163b1e1e9a9b18), C(df3b2aca6e1e4a30),
|
||||
C(ebc34f3c)},
|
||||
{C(11df592596f41d88), C(843ec0bce9042f9c), C(cce2ea1e08b1eb30),
|
||||
C(26f2b463)},
|
||||
{C(831f448bdc5600b3), C(62a24be3120a6919), C(1b44098a41e010da),
|
||||
C(b042c047)},
|
||||
{C(3eca803e70304894), C(d80de767e4a920a), C(a51cfbb292efd53d), C(e73bb0a8)},
|
||||
{C(1b5a063fb4c7f9f1), C(318dbc24af66dee9), C(10ef7b32d5c719af),
|
||||
C(91dfdd75)},
|
||||
{C(a0f10149a0e538d6), C(69d008c20f87419f), C(41b36376185b3e9e),
|
||||
C(c87f95de)},
|
||||
{C(fb8d9c70660b910b), C(a45b0cc3476bff1b), C(b28d1996144f0207),
|
||||
C(3f5538ef)},
|
||||
{C(236827beae282a46), C(e43970221139c946), C(4f3ac6faa837a3aa),
|
||||
C(70eb1a1f)},
|
||||
{C(c385e435136ecf7c), C(d9d17368ff6c4a08), C(1b31eed4e5251a67),
|
||||
C(cfd63b83)},
|
||||
{C(e3f6828b6017086d), C(21b4d1900554b3b0), C(bef38be1809e24f1),
|
||||
C(894a52ef)},
|
||||
{C(851fff285561dca0), C(4d1277d73cdf416f), C(28ccffa61010ebe2),
|
||||
C(9cde6a54)},
|
||||
{C(61152a63595a96d9), C(d1a3a91ef3a7ba45), C(443b6bb4a493ad0c),
|
||||
C(6c4898d5)},
|
||||
{C(44473e03be306c88), C(30097761f872472a), C(9fd1b669bfad82d7),
|
||||
C(13e1978e)},
|
||||
{C(3ead5f21d344056), C(fb6420393cfb05c3), C(407932394cbbd303), C(51b4ba8)},
|
||||
{C(6abbfde37ee03b5b), C(83febf188d2cc113), C(cda7b62d94d5b8ee),
|
||||
C(b6b06e40)},
|
||||
{C(943e7ed63b3c080), C(1ef207e9444ef7f8), C(ef4a9f9f8c6f9b4a), C(240a2f2)},
|
||||
{C(d72ce05171ef8a1a), C(c6bd6bd869203894), C(c760e6396455d23a),
|
||||
C(5dcefc30)},
|
||||
{C(4182832b52d63735), C(337097e123eea414), C(b5a72ca0456df910),
|
||||
C(7a48b105)},
|
||||
{C(d6cdae892584a2cb), C(58de0fa4eca17dcd), C(43df30b8f5f1cb00),
|
||||
C(fd55007b)},
|
||||
{C(5c8e90bc267c5ee4), C(e9ae044075d992d9), C(f234cbfd1f0a1e59),
|
||||
C(6b95894c)},
|
||||
{C(bbd7f30ac310a6f3), C(b23b570d2666685f), C(fb13fb08c9814fe7),
|
||||
C(3360e827)},
|
||||
{C(36a097aa49519d97), C(8204380a73c4065), C(77c2004bdd9e276a), C(45177e0b)},
|
||||
{C(dc78cb032c49217), C(112464083f83e03a), C(96ae53e28170c0f5), C(7c6fffe4)},
|
||||
{C(441593e0da922dfe), C(936ef46061469b32), C(204a1921197ddd87),
|
||||
C(bbc78da4)},
|
||||
{C(2ba3883d71cc2133), C(72f2bbb32bed1a3c), C(27e1bd96d4843251),
|
||||
C(c5c25d39)},
|
||||
{C(f2b6d2adf8423600), C(7514e2f016a48722), C(43045743a50396ba),
|
||||
C(b6e5d06e)},
|
||||
{C(38fffe7f3680d63c), C(d513325255a7a6d1), C(31ed47790f6ca62f),
|
||||
C(6178504e)},
|
||||
{C(b7477bf0b9ce37c6), C(63b1c580a7fd02a4), C(f6433b9f10a5dac), C(bd4c3637)},
|
||||
{C(55bdb0e71e3edebd), C(c7ab562bcf0568bc), C(43166332f9ee684f),
|
||||
C(6e7ac474)},
|
||||
{C(782fa1b08b475e7), C(fb7138951c61b23b), C(9829105e234fb11e), C(1fb4b518)},
|
||||
{C(c5dc19b876d37a80), C(15ffcff666cfd710), C(e8c30c72003103e2),
|
||||
C(31d13d6d)},
|
||||
{C(5e1141711d2d6706), C(b537f6dee8de6933), C(3af0a1fbbe027c54),
|
||||
C(26fa72e3)},
|
||||
{C(782edf6da001234f), C(f48cbd5c66c48f3), C(808754d1e64e2a32), C(6a7433bf)},
|
||||
{C(d26285842ff04d44), C(8f38d71341eacca9), C(5ca436f4db7a883c),
|
||||
C(4e6df758)},
|
||||
{C(c6ab830865a6bae6), C(6aa8e8dd4b98815c), C(efe3846713c371e5),
|
||||
C(d57f63ea)},
|
||||
{C(44b3a1929232892), C(61dca0e914fc217), C(a607cc142096b964), C(52ef73b3)},
|
||||
{C(4b603d7932a8de4f), C(fae64c464b8a8f45), C(8fafab75661d602a), C(3cb36c3)},
|
||||
{C(4ec0b54cf1566aff), C(30d2c7269b206bf4), C(77c22e82295e1061),
|
||||
C(72c39bea)},
|
||||
{C(ed8b7a4b34954ff7), C(56432de31f4ee757), C(85bd3abaa572b155),
|
||||
C(a65aa25c)},
|
||||
{C(5d28b43694176c26), C(714cc8bc12d060ae), C(3437726273a83fe6),
|
||||
C(74740539)},
|
||||
{C(6a1ef3639e1d202e), C(919bc1bd145ad928), C(30f3f7e48c28a773),
|
||||
C(c3ae3c26)},
|
||||
{C(159f4d9e0307b111), C(3e17914a5675a0c), C(af849bd425047b51), C(f29db8a2)},
|
||||
{C(cc0a840725a7e25b), C(57c69454396e193a), C(976eaf7eee0b4540),
|
||||
C(1ef4cbf4)},
|
||||
{C(a2b27ee22f63c3f1), C(9ebde0ce1b3976b2), C(2fe6a92a257af308),
|
||||
C(a9be6c41)},
|
||||
{C(d8f2f234899bcab3), C(b10b037297c3a168), C(debea2c510ceda7f), C(fa31801)},
|
||||
{C(584f28543864844f), C(d7cee9fc2d46f20d), C(a38dca5657387205),
|
||||
C(8331c5d8)},
|
||||
{C(a94be46dd9aa41af), C(a57e5b7723d3f9bd), C(34bf845a52fd2f), C(e9876db8)},
|
||||
{C(9a87bea227491d20), C(a468657e2b9c43e7), C(af9ba60db8d89ef7),
|
||||
C(27b0604e)},
|
||||
{C(27688c24958d1a5c), C(e3b4a1c9429cf253), C(48a95811f70d64bc),
|
||||
C(dcec07f2)},
|
||||
{C(5d1d37790a1873ad), C(ed9cd4bcc5fa1090), C(ce51cde05d8cd96a),
|
||||
C(cff0a82a)},
|
||||
{C(1f03fd18b711eea9), C(566d89b1946d381a), C(6e96e83fc92563ab),
|
||||
C(fec83621)},
|
||||
{C(f0316f286cf527b6), C(f84c29538de1aa5a), C(7612ed3c923d4a71), C(743d8dc)},
|
||||
{C(297008bcb3e3401d), C(61a8e407f82b0c69), C(a4a35bff0524fa0e),
|
||||
C(64d41d26)},
|
||||
{C(43c6252411ee3be), C(b4ca1b8077777168), C(2746dc3f7da1737f), C(acd90c81)},
|
||||
{C(ce38a9a54fad6599), C(6d6f4a90b9e8755e), C(c3ecc79ff105de3f),
|
||||
C(7c746a4b)},
|
||||
{C(270a9305fef70cf), C(600193999d884f3a), C(f4d49eae09ed8a1), C(b1047e99)},
|
||||
{C(e71be7c28e84d119), C(eb6ace59932736e6), C(70c4397807ba12c5),
|
||||
C(d1fd1068)},
|
||||
{C(b5b58c24b53aaa19), C(d2a6ab0773dd897f), C(ef762fe01ecb5b97),
|
||||
C(56486077)},
|
||||
{C(44dd59bd301995cf), C(3ccabd76493ada1a), C(540db4c87d55ef23),
|
||||
C(6069be80)},
|
||||
{C(b4d4789eb6f2630b), C(bf6973263ce8ef0e), C(d1c75c50844b9d3), C(2078359b)},
|
||||
{C(12807833c463737c), C(58e927ea3b3776b4), C(72dd20ef1c2f8ad0),
|
||||
C(9ea21004)},
|
||||
{C(e88419922b87176f), C(bcf32f41a7ddbf6f), C(d6ebefd8085c1a0f),
|
||||
C(9c9cfe88)},
|
||||
{C(105191e0ec8f7f60), C(5918dbfcca971e79), C(6b285c8a944767b9),
|
||||
C(b70a6ddd)},
|
||||
{C(a5b88bf7399a9f07), C(fca3ddfd96461cc4), C(ebe738fdc0282fc6),
|
||||
C(dea37298)},
|
||||
{C(d08c3f5747d84f50), C(4e708b27d1b6f8ac), C(70f70fd734888606),
|
||||
C(8f480819)},
|
||||
{C(2f72d12a40044b4b), C(889689352fec53de), C(f03e6ad87eb2f36), C(30b3b16)},
|
||||
{C(aa1f61fdc5c2e11e), C(c2c56cd11277ab27), C(a1e73069fdf1f94f),
|
||||
C(f31bc4e8)},
|
||||
{C(9489b36fe2246244), C(3355367033be74b8), C(5f57c2277cbce516),
|
||||
C(419f953b)},
|
||||
{C(358d7c0476a044cd), C(e0b7b47bcbd8854f), C(ffb42ec696705519),
|
||||
C(20e9e76d)},
|
||||
{C(b0c48df14275265a), C(9da4448975905efa), C(d716618e414ceb6d),
|
||||
C(646f0ff8)},
|
||||
{C(daa70bb300956588), C(410ea6883a240c6d), C(f5c8239fb5673eb3),
|
||||
C(eeb7eca8)},
|
||||
{C(4ec97a20b6c4c7c2), C(5913b1cd454f29fd), C(a9629f9daf06d685), C(8112bb9)},
|
||||
{C(5c3323628435a2e8), C(1bea45ce9e72a6e3), C(904f0a7027ddb52e),
|
||||
C(85a6d477)},
|
||||
{C(c1ef26bea260abdb), C(6ee423f2137f9280), C(df2118b946ed0b43),
|
||||
C(56f76c84)},
|
||||
{C(6be7381b115d653a), C(ed046190758ea511), C(de6a45ffc3ed1159),
|
||||
C(9af45d55)},
|
||||
{C(ae3eece1711b2105), C(14fd3f4027f81a4a), C(abb7e45177d151db),
|
||||
C(d1c33760)},
|
||||
{C(376c28588b8fb389), C(6b045e84d8491ed2), C(4e857effb7d4e7dc),
|
||||
C(c56bbf69)},
|
||||
{C(58d943503bb6748f), C(419c6c8e88ac70f6), C(586760cbf3d3d368),
|
||||
C(abecfb9b)},
|
||||
{C(dfff5989f5cfd9a1), C(bcee2e7ea3a96f83), C(681c7874adb29017),
|
||||
C(8de13255)},
|
||||
{C(7fb19eb1a496e8f5), C(d49e5dfdb5c0833f), C(c0d5d7b2f7c48dc7),
|
||||
C(a98ee299)},
|
||||
{C(5dba5b0dadccdbaa), C(4ba8da8ded87fcdc), C(f693fdd25badf2f0),
|
||||
C(3015f556)},
|
||||
{C(688bef4b135a6829), C(8d31d82abcd54e8e), C(f95f8a30d55036d7),
|
||||
C(5a430e29)},
|
||||
{C(d8323be05433a412), C(8d48fa2b2b76141d), C(3d346f23978336a5),
|
||||
C(2797add0)},
|
||||
{C(3b5404278a55a7fc), C(23ca0b327c2d0a81), C(a6d65329571c892c),
|
||||
C(27d55016)},
|
||||
{C(2a96a3f96c5e9bbc), C(8caf8566e212dda8), C(904de559ca16e45e),
|
||||
C(84945a82)},
|
||||
{C(22bebfdcc26d18ff), C(4b4d8dcb10807ba1), C(40265eee30c6b896),
|
||||
C(3ef7e224)},
|
||||
{C(627a2249ec6bbcc2), C(c0578b462a46735a), C(4974b8ee1c2d4f1f),
|
||||
C(35ed8dc8)},
|
||||
{C(3abaf1667ba2f3e0), C(ee78476b5eeadc1), C(7e56ac0a6ca4f3f4), C(6a75e43d)},
|
||||
{C(3931ac68c5f1b2c9), C(efe3892363ab0fb0), C(40b707268337cd36),
|
||||
C(235d9805)},
|
||||
{C(b98fb0606f416754), C(46a6e5547ba99c1e), C(c909d82112a8ed2), C(f7d69572)},
|
||||
{C(7f7729a33e58fcc4), C(2e4bc1e7a023ead4), C(e707008ea7ca6222),
|
||||
C(bacd0199)},
|
||||
{C(42a0aa9ce82848b3), C(57232730e6bee175), C(f89bb3f370782031),
|
||||
C(e428f50e)},
|
||||
{C(6b2c6d38408a4889), C(de3ef6f68fb25885), C(20754f456c203361),
|
||||
C(81eaaad3)},
|
||||
{C(930380a3741e862a), C(348d28638dc71658), C(89dedcfd1654ea0d),
|
||||
C(addbd3e3)},
|
||||
{C(94808b5d2aa25f9a), C(cec72968128195e0), C(d9f4da2bdc1e130f),
|
||||
C(e66dbca0)},
|
||||
{C(b31abb08ae6e3d38), C(9eb9a95cbd9e8223), C(8019e79b7ee94ea9),
|
||||
C(afe11fd5)},
|
||||
{C(dccb5534a893ea1a), C(ce71c398708c6131), C(fe2396315457c164),
|
||||
C(a71a406f)},
|
||||
{C(6369163565814de6), C(8feb86fb38d08c2f), C(4976933485cc9a20),
|
||||
C(9d90eaf5)},
|
||||
{C(edee4ff253d9f9b3), C(96ef76fb279ef0ad), C(a4d204d179db2460),
|
||||
C(6665db10)},
|
||||
{C(941993df6e633214), C(929bc1beca5b72c6), C(141fc52b8d55572d),
|
||||
C(9c977cbf)},
|
||||
{C(859838293f64cd4c), C(484403b39d44ad79), C(bf674e64d64b9339),
|
||||
C(ee83ddd4)},
|
||||
{C(c19b5648e0d9f555), C(328e47b2b7562993), C(e756b92ba4bd6a51), C(26519cc)},
|
||||
{C(f963b63b9006c248), C(9e9bf727ffaa00bc), C(c73bacc75b917e3a),
|
||||
C(a485a53f)},
|
||||
{C(6a8aa0852a8c1f3b), C(c8f1e5e206a21016), C(2aa554aed1ebb524),
|
||||
C(f62bc412)},
|
||||
{C(740428b4d45e5fb8), C(4c95a4ce922cb0a5), C(e99c3ba78feae796),
|
||||
C(8975a436)},
|
||||
{C(658b883b3a872b86), C(2f0e303f0f64827a), C(975337e23dc45e1), C(94ff7f41)},
|
||||
{C(6df0a977da5d27d4), C(891dd0e7cb19508), C(fd65434a0b71e680), C(760aa031)},
|
||||
{C(a900275464ae07ef), C(11f2cfda34beb4a3), C(9abf91e5a1c38e4), C(3bda76df)},
|
||||
{C(810bc8aa0c40bcb0), C(448a019568d01441), C(f60ec52f60d3aeae),
|
||||
C(498e2e65)},
|
||||
{C(22036327deb59ed7), C(adc05ceb97026a02), C(48bff0654262672b),
|
||||
C(d38deb48)},
|
||||
{C(7d14dfa9772b00c8), C(595735efc7eeaed7), C(29872854f94c3507),
|
||||
C(82b3fb6b)},
|
||||
{C(2d777cddb912675d), C(278d7b10722a13f9), C(f5c02bfb7cc078af),
|
||||
C(e500e25f)},
|
||||
{C(f2ec98824e8aa613), C(5eb7e3fb53fe3bed), C(12c22860466e1dd4),
|
||||
C(bd2bb07c)},
|
||||
{C(5e763988e21f487f), C(24189de8065d8dc5), C(d1519d2403b62aa0),
|
||||
C(3a2b431d)},
|
||||
{C(48949dc327bb96ad), C(e1fd21636c5c50b4), C(3f6eb7f13a8712b4),
|
||||
C(7322a83d)},
|
||||
{C(b7c4209fb24a85c5), C(b35feb319c79ce10), C(f0d3de191833b922),
|
||||
C(a645ca1c)},
|
||||
{C(9c9e5be0943d4b05), C(b73dc69e45201cbb), C(aab17180bfe5083d),
|
||||
C(8909a45a)},
|
||||
{C(3898bca4dfd6638d), C(f911ff35efef0167), C(24bdf69e5091fc88),
|
||||
C(bd30074c)},
|
||||
{C(5b5d2557400e68e7), C(98d610033574cee), C(dfd08772ce385deb), C(c17cf001)},
|
||||
{C(a927ed8b2bf09bb6), C(606e52f10ae94eca), C(71c2203feb35a9ee),
|
||||
C(26ffd25a)},
|
||||
{C(8d25746414aedf28), C(34b1629d28b33d3a), C(4d5394aea5f82d7b),
|
||||
C(f1d8ce3c)},
|
||||
{C(b5bbdb73458712f2), C(1ff887b3c2a35137), C(7f7231f702d0ace9),
|
||||
C(3ee8fb17)},
|
||||
{C(3d32a26e3ab9d254), C(fc4070574dc30d3a), C(f02629579c2b27c9),
|
||||
C(a77acc2a)},
|
||||
{C(9371d3c35fa5e9a5), C(42967cf4d01f30), C(652d1eeae704145c), C(f4556dee)},
|
||||
{C(cbaa3cb8f64f54e0), C(76c3b48ee5c08417), C(9f7d24e87e61ce9), C(de287a64)},
|
||||
{C(b2e23e8116c2ba9f), C(7e4d9c0060101151), C(3310da5e5028f367),
|
||||
C(878e55b9)},
|
||||
{C(8aa77f52d7868eb9), C(4d55bd587584e6e2), C(d2db37041f495f5), C(7648486)},
|
||||
{C(858fea922c7fe0c3), C(cfe8326bf733bc6f), C(4e5e2018cf8f7dfc),
|
||||
C(57ac0fb1)},
|
||||
{C(46ef25fdec8392b1), C(e48d7b6d42a5cd35), C(56a6fe1c175299ca),
|
||||
C(d01967ca)},
|
||||
{C(8d078f726b2df464), C(b50ee71cdcabb299), C(f4af300106f9c7ba),
|
||||
C(96ecdf74)},
|
||||
{C(35ea86e6960ca950), C(34fe1fe234fc5c76), C(a00207a3dc2a72b7),
|
||||
C(779f5506)},
|
||||
{C(8aee9edbc15dd011), C(51f5839dc8462695), C(b2213e17c37dca2d),
|
||||
C(3c94c2de)},
|
||||
{C(c3e142ba98432dda), C(911d060cab126188), C(b753fbfa8365b844),
|
||||
C(39f98faf)},
|
||||
{C(123ba6b99c8cd8db), C(448e582672ee07c4), C(cebe379292db9e65),
|
||||
C(7af31199)},
|
||||
{C(ba87acef79d14f53), C(b3e0fcae63a11558), C(d5ac313a593a9f45),
|
||||
C(e341a9d6)},
|
||||
{C(bcd3957d5717dc3), C(2da746741b03a007), C(873816f4b1ece472), C(ca24aeeb)},
|
||||
{C(61442ff55609168e), C(6447c5fc76e8c9cf), C(6a846de83ae15728),
|
||||
C(b2252b57)},
|
||||
{C(dbe4b1b2d174757f), C(506512da18712656), C(6857f3e0b8dd95f), C(72c81da1)},
|
||||
{C(531e8e77b363161c), C(eece0b43e2dae030), C(8294b82c78f34ed1),
|
||||
C(6b9fce95)},
|
||||
{C(f71e9c926d711e2b), C(d77af2853a4ceaa1), C(9aa0d6d76a36fae7),
|
||||
C(19399857)},
|
||||
{C(cb20ac28f52df368), C(e6705ee7880996de), C(9b665cc3ec6972f2),
|
||||
C(3c57a994)},
|
||||
{C(e4a794b4acb94b55), C(89795358057b661b), C(9c4cdcec176d7a70),
|
||||
C(c053e729)},
|
||||
{C(cb942e91443e7208), C(e335de8125567c2a), C(d4d74d268b86df1f),
|
||||
C(51cbbba7)},
|
||||
{C(ecca7563c203f7ba), C(177ae2423ef34bb2), C(f60b7243400c5731),
|
||||
C(1acde79a)},
|
||||
{C(1652cb940177c8b5), C(8c4fe7d85d2a6d6d), C(f6216ad097e54e72),
|
||||
C(2d160d13)},
|
||||
{C(31fed0fc04c13ce8), C(3d5d03dbf7ff240a), C(727c5c9b51581203),
|
||||
C(787f5801)},
|
||||
{C(e7b668947590b9b3), C(baa41ad32938d3fa), C(abcbc8d4ca4b39e4),
|
||||
C(c9629828)},
|
||||
{C(1de2119923e8ef3c), C(6ab27c096cf2fe14), C(8c3658edca958891),
|
||||
C(be139231)},
|
||||
{C(1269df1e69e14fa7), C(992f9d58ac5041b7), C(e97fcf695a7cbbb4),
|
||||
C(7df699ef)},
|
||||
{C(820826d7aba567ff), C(1f73d28e036a52f3), C(41c4c5a73f3b0893),
|
||||
C(8ce6b96d)},
|
||||
{C(ffe0547e4923cef9), C(3534ed49b9da5b02), C(548a273700fba03d),
|
||||
C(6f9ed99c)},
|
||||
{C(72da8d1b11d8bc8b), C(ba94b56b91b681c6), C(4e8cc51bd9b0fc8c),
|
||||
C(e0244796)},
|
||||
{C(d62ab4e3f88fc797), C(ea86c7aeb6283ae4), C(b5b93e09a7fe465), C(4ccf7e75)},
|
||||
{C(d0f06c28c7b36823), C(1008cb0874de4bb8), C(d6c7ff816c7a737b),
|
||||
C(915cef86)},
|
||||
{C(99b7042460d72ec6), C(2a53e5e2b8e795c2), C(53a78132d9e1b3e3),
|
||||
C(5cb59482)},
|
||||
{C(4f4dfcfc0ec2bae5), C(841233148268a1b8), C(9248a76ab8be0d3), C(6ca3f532)},
|
||||
{C(fe86bf9d4422b9ae), C(ebce89c90641ef9c), C(1c84e2292c0b5659),
|
||||
C(e24f3859)},
|
||||
{C(a90d81060932dbb0), C(8acfaa88c5fbe92b), C(7c6f3447e90f7f3f),
|
||||
C(adf5a9c7)},
|
||||
{C(17938a1b0e7f5952), C(22cadd2f56f8a4be), C(84b0d1183d5ed7c1),
|
||||
C(32264b75)},
|
||||
{C(de9e0cb0e16f6e6d), C(238e6283aa4f6594), C(4fb9c914c2f0a13b),
|
||||
C(a64b3376)},
|
||||
{C(6d4b876d9b146d1a), C(aab2d64ce8f26739), C(d315f93600e83fe5), C(d33890e)},
|
||||
{C(e698fa3f54e6ea22), C(bd28e20e7455358c), C(9ace161f6ea76e66),
|
||||
C(926d4b63)},
|
||||
{C(7bc0deed4fb349f7), C(1771aff25dc722fa), C(19ff0644d9681917),
|
||||
C(d51ba539)},
|
||||
{C(db4b15e88533f622), C(256d6d2419b41ce9), C(9d7c5378396765d5),
|
||||
C(7f37636d)},
|
||||
{C(922834735e86ecb2), C(363382685b88328e), C(e9c92960d7144630),
|
||||
C(b98026c0)},
|
||||
{C(30f1d72c812f1eb8), C(b567cd4a69cd8989), C(820b6c992a51f0bc),
|
||||
C(b877767e)},
|
||||
{C(168884267f3817e9), C(5b376e050f637645), C(1c18314abd34497a), C(aefae77)},
|
||||
{C(82e78596ee3e56a7), C(25697d9c87f30d98), C(7600a8342834924d), C(f686911)},
|
||||
{C(aa2d6cf22e3cc252), C(9b4dec4f5e179f16), C(76fb0fba1d99a99a),
|
||||
C(3deadf12)},
|
||||
{C(7bf5ffd7f69385c7), C(fc077b1d8bc82879), C(9c04e36f9ed83a24),
|
||||
C(ccf02a4e)},
|
||||
{C(e89c8ff9f9c6e34b), C(f54c0f669a49f6c4), C(fc3e46f5d846adef),
|
||||
C(176c1722)},
|
||||
{C(a18fbcdccd11e1f4), C(8248216751dfd65e), C(40c089f208d89d7c), C(26f82ad)},
|
||||
{C(2d54f40cc4088b17), C(59d15633b0cd1399), C(a8cc04bb1bffd15b),
|
||||
C(b5244f42)},
|
||||
{C(69276946cb4e87c7), C(62bdbe6183be6fa9), C(3ba9773dac442a1a),
|
||||
C(49a689e5)},
|
||||
{C(668174a3f443df1d), C(407299392da1ce86), C(c2a3f7d7f2c5be28), C(59fcdd3)},
|
||||
{C(5e29be847bd5046), C(b561c7f19c8f80c3), C(5e5abd5021ccaeaf), C(4f4b04e9)},
|
||||
{C(cd0d79f2164da014), C(4c386bb5c5d6ca0c), C(8e771b03647c3b63),
|
||||
C(8b00f891)},
|
||||
{C(e0e6fc0b1628af1d), C(29be5fb4c27a2949), C(1c3f781a604d3630),
|
||||
C(16e114f3)},
|
||||
{C(2058927664adfd93), C(6e8f968c7963baa5), C(af3dced6fff7c394),
|
||||
C(d6b6dadc)},
|
||||
{C(dc107285fd8e1af7), C(a8641a0609321f3f), C(db06e89ffdc54466),
|
||||
C(897e20ac)},
|
||||
{C(fbba1afe2e3280f1), C(755a5f392f07fce), C(9e44a9a15402809a), C(f996e05d)},
|
||||
{C(bfa10785ddc1011b), C(b6e1c4d2f670f7de), C(517d95604e4fcc1f),
|
||||
C(c4306af6)},
|
||||
{C(534cc35f0ee1eb4e), C(b703820f1f3b3dce), C(884aa164cf22363), C(6dcad433)},
|
||||
{C(7ca6e3933995dac), C(fd118c77daa8188), C(3aceb7b5e7da6545), C(3c07374d)},
|
||||
{C(f0d6044f6efd7598), C(e044d6ba4369856e), C(91968e4f8c8a1a4c),
|
||||
C(f0f4602c)},
|
||||
{C(3d69e52049879d61), C(76610636ea9f74fe), C(e9bf5602f89310c0),
|
||||
C(3e1ea071)},
|
||||
{C(79da242a16acae31), C(183c5f438e29d40), C(6d351710ae92f3de), C(67580f0c)},
|
||||
{C(461c82656a74fb57), C(d84b491b275aa0f7), C(8f262cb29a6eb8b2),
|
||||
C(4e109454)},
|
||||
{C(53c1a66d0b13003), C(731f060e6fe797fc), C(daa56811791371e3), C(88a474a7)},
|
||||
{C(d3a2efec0f047e9), C(1cabce58853e58ea), C(7a17b2eae3256be4), C(5b5bedd)},
|
||||
{C(43c64d7484f7f9b2), C(5da002b64aafaeb7), C(b576c1e45800a716),
|
||||
C(1aaddfa7)},
|
||||
{C(a7dec6ad81cf7fa1), C(180c1ab708683063), C(95e0fd7008d67cff),
|
||||
C(5be07fd8)},
|
||||
{C(5408a1df99d4aff), C(b9565e588740f6bd), C(abf241813b08006e), C(cbca8606)},
|
||||
{C(a8b27a6bcaeeed4b), C(aec1eeded6a87e39), C(9daf246d6fed8326),
|
||||
C(bde64d01)},
|
||||
{C(9a952a8246fdc269), C(d0dcfcac74ef278c), C(250f7139836f0f1f),
|
||||
C(ee90cf33)},
|
||||
{C(c930841d1d88684f), C(5eb66eb18b7f9672), C(e455d413008a2546),
|
||||
C(4305c3ce)},
|
||||
{C(94dc6971e3cf071a), C(994c7003b73b2b34), C(ea16e85978694e5), C(4b3a1d76)},
|
||||
{C(7fc98006e25cac9), C(77fee0484cda86a7), C(376ec3d447060456), C(a8bb6d80)},
|
||||
{C(bd781c4454103f6), C(612197322f49c931), C(b9cf17fd7e5462d5), C(1f9fa607)},
|
||||
{C(da60e6b14479f9df), C(3bdccf69ece16792), C(18ebf45c4fecfdc9),
|
||||
C(8d0e4ed2)},
|
||||
{C(4ca56a348b6c4d3), C(60618537c3872514), C(2fbb9f0e65871b09), C(1bf31347)},
|
||||
{C(ebd22d4b70946401), C(6863602bf7139017), C(c0b1ac4e11b00666),
|
||||
C(1ae3fc5b)},
|
||||
{C(3cc4693d6cbcb0c), C(501689ea1c70ffa), C(10a4353e9c89e364), C(459c3930)},
|
||||
{C(38908e43f7ba5ef0), C(1ab035d4e7781e76), C(41d133e8c0a68ff7),
|
||||
C(e00c4184)},
|
||||
{C(34983ccc6aa40205), C(21802cad34e72bc4), C(1943e8fb3c17bb8), C(ffc7a781)},
|
||||
{C(86215c45dcac9905), C(ea546afe851cae4b), C(d85b6457e489e374),
|
||||
C(6a125480)},
|
||||
{C(420fc255c38db175), C(d503cd0f3c1208d1), C(d4684e74c825a0bc),
|
||||
C(88a1512b)},
|
||||
{C(1d7a31f5bc8fe2f9), C(4763991092dcf836), C(ed695f55b97416f4),
|
||||
C(549bbbe5)},
|
||||
{C(94129a84c376a26e), C(c245e859dc231933), C(1b8f74fecf917453),
|
||||
C(c133d38c)},
|
||||
{C(1d3a9809dab05c8d), C(adddeb4f71c93e8), C(ef342eb36631edb), C(fcace348)},
|
||||
{C(90fa3ccbd60848da), C(dfa6e0595b569e11), C(e585d067a1f5135d),
|
||||
C(ed7b6f9a)},
|
||||
{C(2dbb4fc71b554514), C(9650e04b86be0f82), C(60f2304fba9274d3),
|
||||
C(6d907dda)},
|
||||
{C(b98bf4274d18374a), C(1b669fd4c7f9a19a), C(b1f5972b88ba2b7a),
|
||||
C(7a4d48d5)},
|
||||
{C(d6781d0b5e18eb68), C(b992913cae09b533), C(58f6021caaee3a40),
|
||||
C(e686f3db)},
|
||||
{C(226651cf18f4884c), C(595052a874f0f51c), C(c9b75162b23bab42), C(cce7c55)},
|
||||
{C(a734fb047d3162d6), C(e523170d240ba3a5), C(125a6972809730e8), C(f58b96b)},
|
||||
{C(c6df6364a24f75a3), C(c294e2c84c4f5df8), C(a88df65c6a89313b),
|
||||
C(1bbf6f60)},
|
||||
{C(d8d1364c1fbcd10), C(2d7cc7f54832deaa), C(4e22c876a7c57625), C(ce5e0cc2)},
|
||||
{C(aae06f9146db885f), C(3598736441e280d9), C(fba339b117083e55),
|
||||
C(584cfd6f)},
|
||||
{C(8955ef07631e3bcc), C(7d70965ea3926f83), C(39aed4134f8b2db6),
|
||||
C(8f9bbc33)},
|
||||
{C(ad611c609cfbe412), C(d3c00b18bf253877), C(90b2172e1f3d0bfd),
|
||||
C(d7640d95)},
|
||||
{C(d5339adc295d5d69), C(b633cc1dcb8b586a), C(ee84184cf5b1aeaf), C(3d12a2b)},
|
||||
{C(40d0aeff521375a8), C(77ba1ad7ecebd506), C(547c6f1a7d9df427),
|
||||
C(aaeafed0)},
|
||||
{C(8b2d54ae1a3df769), C(11e7adaee3216679), C(3483781efc563e03),
|
||||
C(95b9b814)},
|
||||
{C(99c175819b4eae28), C(932e8ff9f7a40043), C(ec78dcab07ca9f7c),
|
||||
C(45fbe66e)},
|
||||
{C(2a418335779b82fc), C(af0295987849a76b), C(c12bc5ff0213f46e),
|
||||
C(b4baa7a8)},
|
||||
{C(3b1fc6a3d279e67d), C(70ea1e49c226396), C(25505adcf104697c), C(83e962fe)},
|
||||
{C(d97eacdf10f1c3c9), C(b54f4654043a36e0), C(b128f6eb09d1234), C(aac3531c)},
|
||||
{C(293a5c1c4e203cd4), C(6b3329f1c130cefe), C(f2e32f8ec76aac91),
|
||||
C(2b1db7cc)},
|
||||
{C(4290e018ffaedde7), C(a14948545418eb5e), C(72d851b202284636),
|
||||
C(cf00cd31)},
|
||||
{C(f919a59cbde8bf2f), C(a56d04203b2dc5a5), C(38b06753ac871e48),
|
||||
C(7d3c43b8)},
|
||||
{C(1d70a3f5521d7fa4), C(fb97b3fdc5891965), C(299d49bbbe3535af),
|
||||
C(cbd5fac6)},
|
||||
{C(6af98d7b656d0d7c), C(d2e99ae96d6b5c0c), C(f63bd1603ef80627),
|
||||
C(76d0fec4)},
|
||||
{C(395b7a8adb96ab75), C(582df7165b20f4a), C(e52bd30e9ff657f9), C(405e3402)},
|
||||
{C(3822dd82c7df012f), C(b9029b40bd9f122b), C(fd25b988468266c4),
|
||||
C(c732c481)},
|
||||
{C(79f7efe4a80b951a), C(dd3a3fddfc6c9c41), C(ab4c812f9e27aa40),
|
||||
C(a8d123c9)},
|
||||
{C(ae6e59f5f055921a), C(e9d9b7bf68e82), C(5ce4e4a5b269cc59), C(1e80ad7d)},
|
||||
{C(8959dbbf07387d36), C(b4658afce48ea35d), C(8f3f82437d8cb8d6),
|
||||
C(52aeb863)},
|
||||
{C(4739613234278a49), C(99ea5bcd340bf663), C(258640912e712b12),
|
||||
C(ef7c0c18)},
|
||||
{C(420e6c926bc54841), C(96dbbf6f4e7c75cd), C(d8d40fa70c3c67bb),
|
||||
C(b6ad4b68)},
|
||||
{C(c8601bab561bc1b7), C(72b26272a0ff869a), C(56fdfc986d6bc3c4),
|
||||
C(c1e46b17)},
|
||||
{C(b2d294931a0e20eb), C(284ffd9a0815bc38), C(1f8a103aac9bbe6), C(57b8df25)},
|
||||
{C(7966f53c37b6c6d7), C(8e6abcfb3aa2b88f), C(7f2e5e0724e5f345),
|
||||
C(e9fa36d6)},
|
||||
{C(be9bb0abd03b7368), C(13bca93a3031be55), C(e864f4f52b55b472),
|
||||
C(8f8daefc)},
|
||||
{C(a08d128c5f1649be), C(a8166c3dbbe19aad), C(cb9f914f829ec62c), C(6e1bb7e)},
|
||||
{C(7c386f0ffe0465ac), C(530419c9d843dbf3), C(7450e3a4f72b8d8c),
|
||||
C(fd0076f0)},
|
||||
{C(bb362094e7ef4f8), C(ff3c2a48966f9725), C(55152803acd4a7fe), C(899b17b6)},
|
||||
{C(cd80dea24321eea4), C(52b4fdc8130c2b15), C(f3ea100b154bfb82),
|
||||
C(e3e84e31)},
|
||||
{C(d599a04125372c3a), C(313136c56a56f363), C(1e993c3677625832),
|
||||
C(eef79b6b)},
|
||||
{C(dbbf541e9dfda0a), C(1479fceb6db4f844), C(31ab576b59062534), C(868e3315)},
|
||||
{C(c2ee3288be4fe2bf), C(c65d2f5ddf32b92), C(af6ecdf121ba5485), C(4639a426)},
|
||||
{C(d86603ced1ed4730), C(f9de718aaada7709), C(db8b9755194c6535),
|
||||
C(f3213646)},
|
||||
{C(915263c671b28809), C(a815378e7ad762fd), C(abec6dc9b669f559),
|
||||
C(17f148e9)},
|
||||
{C(2b67cdd38c307a5e), C(cb1d45bb5c9fe1c), C(800baf2a02ec18ad), C(bfd94880)},
|
||||
{C(2d107419073b9cd0), C(a96db0740cef8f54), C(ec41ee91b3ecdc1b),
|
||||
C(bb1fa7f3)},
|
||||
{C(f3e9487ec0e26dfc), C(1ab1f63224e837fa), C(119983bb5a8125d8), C(88816b1)},
|
||||
{C(1160987c8fe86f7d), C(879e6db1481eb91b), C(d7dcb802bfe6885d),
|
||||
C(5c2faeb3)},
|
||||
{C(eab8112c560b967b), C(97f550b58e89dbae), C(846ed506d304051f),
|
||||
C(51b5fc6f)},
|
||||
{C(1addcf0386d35351), C(b5f436561f8f1484), C(85d38e22181c9bb1),
|
||||
C(33d94752)},
|
||||
{C(d445ba84bf803e09), C(1216c2497038f804), C(2293216ea2237207),
|
||||
C(b0c92948)},
|
||||
{C(37235a096a8be435), C(d9b73130493589c2), C(3b1024f59378d3be),
|
||||
C(c7171590)},
|
||||
{C(763ad6ea2fe1c99d), C(cf7af5368ac1e26b), C(4d5e451b3bb8d3d4),
|
||||
C(240a67fb)},
|
||||
{C(ea627fc84cd1b857), C(85e372494520071f), C(69ec61800845780b),
|
||||
C(e1843cd5)},
|
||||
{C(1f2ffd79f2cdc0c8), C(726a1bc31b337aaa), C(678b7f275ef96434),
|
||||
C(fda1452b)},
|
||||
{C(39a9e146ec4b3210), C(f63f75802a78b1ac), C(e2e22539c94741c3),
|
||||
C(a2cad330)},
|
||||
{C(74cba303e2dd9d6d), C(692699b83289fad1), C(dfb9aa7874678480),
|
||||
C(53467e16)},
|
||||
{C(4cbc2b73a43071e0), C(56c5db4c4ca4e0b7), C(1b275a162f46bd3d),
|
||||
C(da14a8d0)},
|
||||
{C(875638b9715d2221), C(d9ba0615c0c58740), C(616d4be2dfe825aa),
|
||||
C(67333551)},
|
||||
{C(fb686b2782994a8d), C(edee60693756bb48), C(e6bc3cae0ded2ef5),
|
||||
C(a0ebd66e)},
|
||||
{C(ab21d81a911e6723), C(4c31b07354852f59), C(835da384c9384744),
|
||||
C(4b769593)},
|
||||
{C(33d013cc0cd46ecf), C(3de726423aea122c), C(116af51117fe21a9),
|
||||
C(6aa75624)},
|
||||
{C(8ca92c7cd39fae5d), C(317e620e1bf20f1), C(4f0b33bf2194b97f), C(602a3f96)},
|
||||
{C(fdde3b03f018f43e), C(38f932946c78660), C(c84084ce946851ee), C(cd183c4d)},
|
||||
{C(9c8502050e9c9458), C(d6d2a1a69964beb9), C(1675766f480229b5),
|
||||
C(960a4d07)},
|
||||
{C(348176ca2fa2fdd2), C(3a89c514cc360c2d), C(9f90b8afb318d6d0),
|
||||
C(9ae998c4)},
|
||||
{C(4a3d3dfbbaea130b), C(4e221c920f61ed01), C(553fd6cd1304531f),
|
||||
C(74e2179d)},
|
||||
{C(b371f768cdf4edb9), C(bdef2ace6d2de0f0), C(e05b4100f7f1baec),
|
||||
C(ee9bae25)},
|
||||
{C(7a1d2e96934f61f), C(eb1760ae6af7d961), C(887eb0da063005df), C(b66edf10)},
|
||||
{C(8be53d466d4728f2), C(86a5ac8e0d416640), C(984aa464cdb5c8bb),
|
||||
C(d6209737)},
|
||||
{C(829677eb03abf042), C(43cad004b6bc2c0), C(f2f224756803971a), C(b994a88)},
|
||||
{C(754435bae3496fc), C(5707fc006f094dcf), C(8951c86ab19d8e40), C(a05d43c0)},
|
||||
{C(fda9877ea8e3805f), C(31e868b6ffd521b7), C(b08c90681fb6a0fd),
|
||||
C(c79f73a8)},
|
||||
{C(2e36f523ca8f5eb5), C(8b22932f89b27513), C(331cd6ecbfadc1bb),
|
||||
C(a490aff5)},
|
||||
{C(21a378ef76828208), C(a5c13037fa841da2), C(506d22a53fbe9812),
|
||||
C(dfad65b4)},
|
||||
{C(ccdd5600054b16ca), C(f78846e84204cb7b), C(1f9faec82c24eac9), C(1d07dfb)},
|
||||
{C(7854468f4e0cabd0), C(3a3f6b4f098d0692), C(ae2423ec7799d30d),
|
||||
C(416df9a0)},
|
||||
{C(7f88db5346d8f997), C(88eac9aacc653798), C(68a4d0295f8eefa1),
|
||||
C(1f8fb9cc)},
|
||||
{C(bb3fb5fb01d60fcf), C(1b7cc0847a215eb6), C(1246c994437990a1),
|
||||
C(7abf48e3)},
|
||||
{C(2e783e1761acd84d), C(39158042bac975a0), C(1cd21c5a8071188d),
|
||||
C(dea4e3dd)},
|
||||
{C(392058251cf22acc), C(944ec4475ead4620), C(b330a10b5cb94166),
|
||||
C(c6064f22)},
|
||||
{C(adf5c1e5d6419947), C(2a9747bc659d28aa), C(95c5b8cb1f5d62c), C(743bed9c)},
|
||||
{C(6bc1db2c2bee5aba), C(e63b0ed635307398), C(7b2eca111f30dbbc),
|
||||
C(fce254d5)},
|
||||
{C(b00f898229efa508), C(83b7590ad7f6985c), C(2780e70a0592e41d),
|
||||
C(e47ec9d1)},
|
||||
{C(b56eb769ce0d9a8c), C(ce196117bfbcaf04), C(b26c3c3797d66165),
|
||||
C(334a145c)},
|
||||
{C(70c0637675b94150), C(259e1669305b0a15), C(46e1dd9fd387a58d),
|
||||
C(adec1e3c)},
|
||||
{C(74c0b8a6821faafe), C(abac39d7491370e7), C(faf0b2a48a4e6aed),
|
||||
C(f6a9fbf8)},
|
||||
{C(5fb5e48ac7b7fa4f), C(a96170f08f5acbc7), C(bbf5c63d4f52a1e5),
|
||||
C(5398210c)},
|
||||
};
|
||||
|
||||
void TestUnchanging(const uint64_t* expected, int offset, int len) {
|
||||
EXPECT_EQ(expected[0], CityHash64(data + offset, len));
|
||||
EXPECT_EQ(expected[3], CityHash32(data + offset, len));
|
||||
EXPECT_EQ(expected[1], CityHash64WithSeed(data + offset, len, kSeed0));
|
||||
EXPECT_EQ(expected[2],
|
||||
CityHash64WithSeeds(data + offset, len, kSeed0, kSeed1));
|
||||
}
|
||||
|
||||
TEST(CityHashTest, Unchanging) {
|
||||
setup();
|
||||
int i = 0;
|
||||
for (; i < kTestSize - 1; i++) {
|
||||
TestUnchanging(testdata[i], i * i, i);
|
||||
}
|
||||
TestUnchanging(testdata[i], 0, kDataSize);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
69
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash.cc
Normal file
69
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash.cc
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/hash/internal/hash.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/hash/internal/low_level_hash.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
uint64_t MixingHashState::CombineLargeContiguousImpl32(
|
||||
uint64_t state, const unsigned char* first, size_t len) {
|
||||
while (len >= PiecewiseChunkSize()) {
|
||||
state = Mix(
|
||||
state ^ hash_internal::CityHash32(reinterpret_cast<const char*>(first),
|
||||
PiecewiseChunkSize()),
|
||||
kMul);
|
||||
len -= PiecewiseChunkSize();
|
||||
first += PiecewiseChunkSize();
|
||||
}
|
||||
// Handle the remainder.
|
||||
return CombineContiguousImpl(state, first, len,
|
||||
std::integral_constant<int, 4>{});
|
||||
}
|
||||
|
||||
uint64_t MixingHashState::CombineLargeContiguousImpl64(
|
||||
uint64_t state, const unsigned char* first, size_t len) {
|
||||
while (len >= PiecewiseChunkSize()) {
|
||||
state = Mix(state ^ Hash64(first, PiecewiseChunkSize()), kMul);
|
||||
len -= PiecewiseChunkSize();
|
||||
first += PiecewiseChunkSize();
|
||||
}
|
||||
// Handle the remainder.
|
||||
return CombineContiguousImpl(state, first, len,
|
||||
std::integral_constant<int, 8>{});
|
||||
}
|
||||
|
||||
ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed;
|
||||
|
||||
#ifdef ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
|
||||
constexpr uint64_t MixingHashState::kStaticRandomData[];
|
||||
#endif
|
||||
|
||||
uint64_t MixingHashState::LowLevelHashImpl(const unsigned char* data,
|
||||
size_t len) {
|
||||
return LowLevelHashLenGt16(data, len, Seed(), &kStaticRandomData[0]);
|
||||
}
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
1486
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash.h
Normal file
1486
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash.h
Normal file
File diff suppressed because it is too large
Load diff
87
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash_test.h
Normal file
87
TMessagesProj/jni/voip/webrtc/absl/hash/internal/hash_test.h
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
// Copyright 2023 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Common code shared between absl/hash/hash_test.cc and
|
||||
// absl/hash/hash_instantiated_test.cc.
|
||||
|
||||
#ifndef ABSL_HASH_INTERNAL_HASH_TEST_H_
|
||||
#define ABSL_HASH_INTERNAL_HASH_TEST_H_
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/hash/hash.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_test_internal {
|
||||
|
||||
// Utility wrapper of T for the purposes of testing the `AbslHash` type erasure
|
||||
// mechanism. `TypeErasedValue<T>` can be constructed with a `T`, and can
|
||||
// be compared and hashed. However, all hashing goes through the hashing
|
||||
// type-erasure framework.
|
||||
template <typename T>
|
||||
class TypeErasedValue {
|
||||
public:
|
||||
TypeErasedValue() = default;
|
||||
TypeErasedValue(const TypeErasedValue&) = default;
|
||||
TypeErasedValue(TypeErasedValue&&) = default;
|
||||
explicit TypeErasedValue(const T& n) : n_(n) {}
|
||||
|
||||
template <typename H>
|
||||
friend H AbslHashValue(H hash_state, const TypeErasedValue& v) {
|
||||
v.HashValue(absl::HashState::Create(&hash_state));
|
||||
return hash_state;
|
||||
}
|
||||
|
||||
void HashValue(absl::HashState state) const {
|
||||
absl::HashState::combine(std::move(state), n_);
|
||||
}
|
||||
|
||||
bool operator==(const TypeErasedValue& rhs) const { return n_ == rhs.n_; }
|
||||
bool operator!=(const TypeErasedValue& rhs) const { return !(*this == rhs); }
|
||||
|
||||
private:
|
||||
T n_;
|
||||
};
|
||||
|
||||
// A TypeErasedValue refinement, for containers. It exposes the wrapped
|
||||
// `value_type` and is constructible from an initializer list.
|
||||
template <typename T>
|
||||
class TypeErasedContainer : public TypeErasedValue<T> {
|
||||
public:
|
||||
using value_type = typename T::value_type;
|
||||
TypeErasedContainer() = default;
|
||||
TypeErasedContainer(const TypeErasedContainer&) = default;
|
||||
TypeErasedContainer(TypeErasedContainer&&) = default;
|
||||
explicit TypeErasedContainer(const T& n) : TypeErasedValue<T>(n) {}
|
||||
TypeErasedContainer(std::initializer_list<value_type> init_list)
|
||||
: TypeErasedContainer(T(init_list.begin(), init_list.end())) {}
|
||||
// one-argument constructor of value type T, to appease older toolchains that
|
||||
// get confused by one-element initializer lists in some contexts
|
||||
explicit TypeErasedContainer(const value_type& v)
|
||||
: TypeErasedContainer(T(&v, &v + 1)) {}
|
||||
};
|
||||
|
||||
// Helper trait to verify if T is hashable. We use absl::Hash's poison status to
|
||||
// detect it.
|
||||
template <typename T>
|
||||
using is_hashable = std::is_default_constructible<absl::Hash<T>>;
|
||||
|
||||
} // namespace hash_test_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_INTERNAL_HASH_TEST_H_
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
// Copyright 2020 The Abseil Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/hash/internal/low_level_hash.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "absl/base/internal/unaligned_access.h"
|
||||
#include "absl/base/prefetch.h"
|
||||
#include "absl/numeric/int128.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
static uint64_t Mix(uint64_t v0, uint64_t v1) {
|
||||
absl::uint128 p = v0;
|
||||
p *= v1;
|
||||
return absl::Uint128Low64(p) ^ absl::Uint128High64(p);
|
||||
}
|
||||
|
||||
uint64_t LowLevelHashLenGt16(const void* data, size_t len, uint64_t seed,
|
||||
const uint64_t salt[5]) {
|
||||
const uint8_t* ptr = static_cast<const uint8_t*>(data);
|
||||
uint64_t starting_length = static_cast<uint64_t>(len);
|
||||
const uint8_t* last_16_ptr = ptr + starting_length - 16;
|
||||
uint64_t current_state = seed ^ salt[0];
|
||||
|
||||
if (len > 64) {
|
||||
// If we have more than 64 bytes, we're going to handle chunks of 64
|
||||
// bytes at a time. We're going to build up four separate hash states
|
||||
// which we will then hash together. This avoids short dependency chains.
|
||||
uint64_t duplicated_state0 = current_state;
|
||||
uint64_t duplicated_state1 = current_state;
|
||||
uint64_t duplicated_state2 = current_state;
|
||||
|
||||
do {
|
||||
// Always prefetch the next cacheline.
|
||||
PrefetchToLocalCache(ptr + ABSL_CACHELINE_SIZE);
|
||||
|
||||
uint64_t a = absl::base_internal::UnalignedLoad64(ptr);
|
||||
uint64_t b = absl::base_internal::UnalignedLoad64(ptr + 8);
|
||||
uint64_t c = absl::base_internal::UnalignedLoad64(ptr + 16);
|
||||
uint64_t d = absl::base_internal::UnalignedLoad64(ptr + 24);
|
||||
uint64_t e = absl::base_internal::UnalignedLoad64(ptr + 32);
|
||||
uint64_t f = absl::base_internal::UnalignedLoad64(ptr + 40);
|
||||
uint64_t g = absl::base_internal::UnalignedLoad64(ptr + 48);
|
||||
uint64_t h = absl::base_internal::UnalignedLoad64(ptr + 56);
|
||||
|
||||
current_state = Mix(a ^ salt[1], b ^ current_state);
|
||||
duplicated_state0 = Mix(c ^ salt[2], d ^ duplicated_state0);
|
||||
|
||||
duplicated_state1 = Mix(e ^ salt[3], f ^ duplicated_state1);
|
||||
duplicated_state2 = Mix(g ^ salt[4], h ^ duplicated_state2);
|
||||
|
||||
ptr += 64;
|
||||
len -= 64;
|
||||
} while (len > 64);
|
||||
|
||||
current_state = (current_state ^ duplicated_state0) ^
|
||||
(duplicated_state1 + duplicated_state2);
|
||||
}
|
||||
|
||||
// We now have a data `ptr` with at most 64 bytes and the current state
|
||||
// of the hashing state machine stored in current_state.
|
||||
if (len > 32) {
|
||||
uint64_t a = absl::base_internal::UnalignedLoad64(ptr);
|
||||
uint64_t b = absl::base_internal::UnalignedLoad64(ptr + 8);
|
||||
uint64_t c = absl::base_internal::UnalignedLoad64(ptr + 16);
|
||||
uint64_t d = absl::base_internal::UnalignedLoad64(ptr + 24);
|
||||
|
||||
uint64_t cs0 = Mix(a ^ salt[1], b ^ current_state);
|
||||
uint64_t cs1 = Mix(c ^ salt[2], d ^ current_state);
|
||||
current_state = cs0 ^ cs1;
|
||||
|
||||
ptr += 32;
|
||||
len -= 32;
|
||||
}
|
||||
|
||||
// We now have a data `ptr` with at most 32 bytes and the current state
|
||||
// of the hashing state machine stored in current_state.
|
||||
if (len > 16) {
|
||||
uint64_t a = absl::base_internal::UnalignedLoad64(ptr);
|
||||
uint64_t b = absl::base_internal::UnalignedLoad64(ptr + 8);
|
||||
|
||||
current_state = Mix(a ^ salt[1], b ^ current_state);
|
||||
}
|
||||
|
||||
// We now have a data `ptr` with at least 1 and at most 16 bytes. But we can
|
||||
// safely read from `ptr + len - 16`.
|
||||
uint64_t a = absl::base_internal::UnalignedLoad64(last_16_ptr);
|
||||
uint64_t b = absl::base_internal::UnalignedLoad64(last_16_ptr + 8);
|
||||
|
||||
return Mix(a ^ salt[1] ^ starting_length, b ^ current_state);
|
||||
}
|
||||
|
||||
uint64_t LowLevelHash(const void* data, size_t len, uint64_t seed,
|
||||
const uint64_t salt[5]) {
|
||||
if (len > 16) return LowLevelHashLenGt16(data, len, seed, salt);
|
||||
|
||||
// Prefetch the cacheline that data resides in.
|
||||
PrefetchToLocalCache(data);
|
||||
const uint8_t* ptr = static_cast<const uint8_t*>(data);
|
||||
uint64_t starting_length = static_cast<uint64_t>(len);
|
||||
uint64_t current_state = seed ^ salt[0];
|
||||
if (len == 0) return current_state;
|
||||
|
||||
uint64_t a = 0;
|
||||
uint64_t b = 0;
|
||||
|
||||
// We now have a data `ptr` with at least 1 and at most 16 bytes.
|
||||
if (len > 8) {
|
||||
// When we have at least 9 and at most 16 bytes, set A to the first 64
|
||||
// bits of the input and B to the last 64 bits of the input. Yes, they
|
||||
// will overlap in the middle if we are working with less than the full 16
|
||||
// bytes.
|
||||
a = absl::base_internal::UnalignedLoad64(ptr);
|
||||
b = absl::base_internal::UnalignedLoad64(ptr + len - 8);
|
||||
} else if (len > 3) {
|
||||
// If we have at least 4 and at most 8 bytes, set A to the first 32
|
||||
// bits and B to the last 32 bits.
|
||||
a = absl::base_internal::UnalignedLoad32(ptr);
|
||||
b = absl::base_internal::UnalignedLoad32(ptr + len - 4);
|
||||
} else {
|
||||
// If we have at least 1 and at most 3 bytes, read 2 bytes into A and the
|
||||
// other byte into B, with some adjustments.
|
||||
a = static_cast<uint64_t>((ptr[0] << 8) | ptr[len - 1]);
|
||||
b = static_cast<uint64_t>(ptr[len >> 1]);
|
||||
}
|
||||
|
||||
return Mix(a ^ salt[1] ^ starting_length, b ^ current_state);
|
||||
}
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// Copyright 2020 The Abseil Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file provides the Google-internal implementation of LowLevelHash.
|
||||
//
|
||||
// LowLevelHash is a fast hash function for hash tables, the fastest we've
|
||||
// currently (late 2020) found that passes the SMHasher tests. The algorithm
|
||||
// relies on intrinsic 128-bit multiplication for speed. This is not meant to be
|
||||
// secure - just fast.
|
||||
//
|
||||
// It is closely based on a version of wyhash, but does not maintain or
|
||||
// guarantee future compatibility with it.
|
||||
|
||||
#ifndef ABSL_HASH_INTERNAL_LOW_LEVEL_HASH_H_
|
||||
#define ABSL_HASH_INTERNAL_LOW_LEVEL_HASH_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
// Hash function for a byte array. A 64-bit seed and a set of five 64-bit
|
||||
// integers are hashed into the result.
|
||||
//
|
||||
// To allow all hashable types (including string_view and Span) to depend on
|
||||
// this algorithm, we keep the API low-level, with as few dependencies as
|
||||
// possible.
|
||||
uint64_t LowLevelHash(const void* data, size_t len, uint64_t seed,
|
||||
const uint64_t salt[5]);
|
||||
|
||||
// Same as above except the length must be greater than 16.
|
||||
uint64_t LowLevelHashLenGt16(const void* data, size_t len, uint64_t seed,
|
||||
const uint64_t salt[5]);
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_INTERNAL_LOW_LEVEL_HASH_H_
|
||||
|
|
@ -0,0 +1,532 @@
|
|||
// Copyright 2020 The Abseil Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "absl/hash/internal/low_level_hash.h"
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
|
||||
#define UPDATE_GOLDEN 0
|
||||
|
||||
namespace {
|
||||
|
||||
static const uint64_t kSalt[5] = {0xa0761d6478bd642f, 0xe7037ed1a0b428dbl,
|
||||
0x8ebc6af09c88c6e3, 0x589965cc75374cc3l,
|
||||
0x1d8e4e27c47d124f};
|
||||
|
||||
TEST(LowLevelHashTest, VerifyGolden) {
|
||||
constexpr size_t kNumGoldenOutputs = 134;
|
||||
static struct {
|
||||
absl::string_view base64_data;
|
||||
uint64_t seed;
|
||||
} cases[] = {
|
||||
{"", uint64_t{0xec42b7ab404b8acb}},
|
||||
{"ICAg", uint64_t{0}},
|
||||
{"YWFhYQ==", uint64_t{0}},
|
||||
{"AQID", uint64_t{0}},
|
||||
{"AQIDBA==", uint64_t{0}},
|
||||
{"dGhpcmRfcGFydHl8d3loYXNofDY0", uint64_t{0}},
|
||||
{"Zw==", uint64_t{0xeeee074043a3ee0f}},
|
||||
{"xmk=", uint64_t{0x857902089c393de}},
|
||||
{"c1H/", uint64_t{0x993df040024ca3af}},
|
||||
{"SuwpzQ==", uint64_t{0xc4e4c2acea740e96}},
|
||||
{"uqvy++M=", uint64_t{0x6a214b3db872d0cf}},
|
||||
{"RnzCVPgb", uint64_t{0x44343db6a89dba4d}},
|
||||
{"6OeNdlouYw==", uint64_t{0x77b5d6d1ae1dd483}},
|
||||
{"M5/JmmYyDbc=", uint64_t{0x89ab8ecb44d221f1}},
|
||||
{"MVijWiVdBRdY", uint64_t{0x60244b17577ca81b}},
|
||||
{"6V7Uq7LNxpu0VA==", uint64_t{0x59a08dcee0717067}},
|
||||
{"EQ6CdEEhPdyHcOk=", uint64_t{0xf5f20db3ade57396}},
|
||||
{"PqFB4fxnPgF+l+rc", uint64_t{0xbf8dee0751ad3efb}},
|
||||
{"a5aPOFwq7LA7+zKvPA==", uint64_t{0x6b7a06b268d63e30}},
|
||||
{"VOwY21wCGv5D+/qqOvs=", uint64_t{0xb8c37f0ae0f54c82}},
|
||||
{"KdHmBTx8lHXYvmGJ+Vy7", uint64_t{0x9fcbed0c38e50eef}},
|
||||
{"qJkPlbHr8bMF7/cA6aE65Q==", uint64_t{0x2af4bade1d8e3a1d}},
|
||||
{"ygvL0EhHZL0fIx6oHHtkxRQ=", uint64_t{0x714e3aa912da2f2c}},
|
||||
{"c1rFXkt5YztwZCQRngncqtSs", uint64_t{0xf5ee75e3cbb82c1c}},
|
||||
{"8hsQrzszzeNQSEcVXLtvIhm6mw==", uint64_t{0x620e7007321b93b9}},
|
||||
{"ffUL4RocfyP4KfikGxO1yk7omDI=", uint64_t{0xc08528cac2e551fc}},
|
||||
{"OOB5TT00vF9Od/rLbAWshiErqhpV", uint64_t{0x6a1debf9cc3ad39}},
|
||||
{"or5wtXM7BFzTNpSzr+Lw5J5PMhVJ/Q==", uint64_t{0x7e0a3c88111fc226}},
|
||||
{"gk6pCHDUsoopVEiaCrzVDhioRKxb844=", uint64_t{0x1301fef15df39edb}},
|
||||
{"TNctmwlC5QbEM6/No4R/La3UdkfeMhzs", uint64_t{0x64e181f3d5817ab}},
|
||||
{"SsQw9iAjhWz7sgcE9OwLuSC6hsM+BfHs2Q==", uint64_t{0xafafc44961078ecb}},
|
||||
{"ZzO3mVCj4xTT2TT3XqDyEKj2BZQBvrS8RHg=", uint64_t{0x4f7bb45549250094}},
|
||||
{"+klp5iPQGtppan5MflEls0iEUzqU+zGZkDJX", uint64_t{0xa30061abaa2818c}},
|
||||
{"RO6bvOnlJc8I9eniXlNgqtKy0IX6VNg16NRmgg==",
|
||||
uint64_t{0xd902ee3e44a5705f}},
|
||||
{"ZJjZqId1ZXBaij9igClE3nyliU5XWdNRrayGlYA=", uint64_t{0x316d36da516f583}},
|
||||
{"7BfkhfGMDGbxfMB8uyL85GbaYQtjr2K8g7RpLzr/",
|
||||
uint64_t{0x402d83f9f834f616}},
|
||||
{"rycWk6wHH7htETQtje9PidS2YzXBx+Qkg2fY7ZYS7A==",
|
||||
uint64_t{0x9c604164c016b72c}},
|
||||
{"RTkC2OUK+J13CdGllsH0H5WqgspsSa6QzRZouqx6pvI=",
|
||||
uint64_t{0x3f4507e01f9e73ba}},
|
||||
{"tKjKmbLCNyrLCM9hycOAXm4DKNpM12oZ7dLTmUx5iwAi",
|
||||
uint64_t{0xc3fe0d5be8d2c7c7}},
|
||||
{"VprUGNH+5NnNRaORxgH/ySrZFQFDL+4VAodhfBNinmn8cg==",
|
||||
uint64_t{0x531858a40bfa7ea1}},
|
||||
{"gc1xZaY+q0nPcUvOOnWnT3bqfmT/geth/f7Dm2e/DemMfk4=",
|
||||
uint64_t{0x86689478a7a7e8fa}},
|
||||
{"Mr35fIxqx1ukPAL0su1yFuzzAU3wABCLZ8+ZUFsXn47UmAph",
|
||||
uint64_t{0x4ec948b8e7f27288}},
|
||||
{"A9G8pw2+m7+rDtWYAdbl8tb2fT7FFo4hLi2vAsa5Y8mKH3CX3g==",
|
||||
uint64_t{0xce46c7213c10032}},
|
||||
{"DFaJGishGwEHDdj9ixbCoaTjz9KS0phLNWHVVdFsM93CvPft3hM=",
|
||||
uint64_t{0xf63e96ee6f32a8b6}},
|
||||
{"7+Ugx+Kr3aRNgYgcUxru62YkTDt5Hqis+2po81hGBkcrJg4N0uuy",
|
||||
uint64_t{0x1cfe85e65fc5225}},
|
||||
{"H2w6O8BUKqu6Tvj2xxaecxEI2wRgIgqnTTG1WwOgDSINR13Nm4d4Vg==",
|
||||
uint64_t{0x45c474f1cee1d2e8}},
|
||||
{"1XBMnIbqD5jy65xTDaf6WtiwtdtQwv1dCVoqpeKj+7cTR1SaMWMyI04=",
|
||||
uint64_t{0x6e024e14015f329c}},
|
||||
{"znZbdXG2TSFrKHEuJc83gPncYpzXGbAebUpP0XxzH0rpe8BaMQ17nDbt",
|
||||
uint64_t{0x760c40502103ae1c}},
|
||||
{"ylu8Atu13j1StlcC1MRMJJXIl7USgDDS22HgVv0WQ8hx/8pNtaiKB17hCQ==",
|
||||
uint64_t{0x17fd05c3c560c320}},
|
||||
{"M6ZVVzsd7vAvbiACSYHioH/440dp4xG2mLlBnxgiqEvI/aIEGpD0Sf4VS0g=",
|
||||
uint64_t{0x8b34200a6f8e90d9}},
|
||||
{"li3oFSXLXI+ubUVGJ4blP6mNinGKLHWkvGruun85AhVn6iuMtocbZPVhqxzn",
|
||||
uint64_t{0x6be89e50818bdf69}},
|
||||
{"kFuQHuUCqBF3Tc3hO4dgdIp223ShaCoog48d5Do5zMqUXOh5XpGK1t5XtxnfGA==",
|
||||
uint64_t{0xfb389773315b47d8}},
|
||||
{"jWmOad0v0QhXVJd1OdGuBZtDYYS8wBVHlvOeTQx9ZZnm8wLEItPMeihj72E0nWY=",
|
||||
uint64_t{0x4f2512a23f61efee}},
|
||||
{"z+DHU52HaOQdW4JrZwDQAebEA6rm13Zg/9lPYA3txt3NjTBqFZlOMvTRnVzRbl23",
|
||||
uint64_t{0x59ccd92fc16c6fda}},
|
||||
{"MmBiGDfYeTayyJa/tVycg+rN7f9mPDFaDc+23j0TlW9094er0ADigsl4QX7V3gG/qw==",
|
||||
uint64_t{0x25c5a7f5bd330919}},
|
||||
{"774RK+9rOL4iFvs1q2qpo/JVc/I39buvNjqEFDtDvyoB0FXxPI2vXqOrk08VPfIHkmU=",
|
||||
uint64_t{0x51df4174d34c97d7}},
|
||||
{"+slatXiQ7/2lK0BkVUI1qzNxOOLP3I1iK6OfHaoxgqT63FpzbElwEXSwdsryq3UlHK0I",
|
||||
uint64_t{0x80ce6d76f89cb57}},
|
||||
{"64mVTbQ47dHjHlOHGS/hjJwr/"
|
||||
"K2frCNpn87exOqMzNUVYiPKmhCbfS7vBUce5tO6Ec9osQ==",
|
||||
uint64_t{0x20961c911965f684}},
|
||||
{"fIsaG1r530SFrBqaDj1kqE0AJnvvK8MNEZbII2Yw1OK77v0V59xabIh0B5axaz/"
|
||||
"+a2V5WpA=",
|
||||
uint64_t{0x4e5b926ec83868e7}},
|
||||
{"PGih0zDEOWCYGxuHGDFu9Ivbff/"
|
||||
"iE7BNUq65tycTR2R76TerrXALRosnzaNYO5fjFhTi+CiS",
|
||||
uint64_t{0x3927b30b922eecef}},
|
||||
{"RnpA/"
|
||||
"zJnEnnLjmICORByRVb9bCOgxF44p3VMiW10G7PvW7IhwsWajlP9kIwNA9FjAD2GoQHk2Q="
|
||||
"=",
|
||||
uint64_t{0xbd0291284a49b61c}},
|
||||
{"qFklMceaTHqJpy2qavJE+EVBiNFOi6OxjOA3LeIcBop1K7w8xQi3TrDk+"
|
||||
"BrWPRIbfprszSaPfrI=",
|
||||
uint64_t{0x73a77c575bcc956}},
|
||||
{"cLbfUtLl3EcQmITWoTskUR8da/VafRDYF/ylPYwk7/"
|
||||
"zazk6ssyrzxMN3mmSyvrXR2yDGNZ3WDrTT",
|
||||
uint64_t{0x766a0e2ade6d09a6}},
|
||||
{"s/"
|
||||
"Jf1+"
|
||||
"FbsbCpXWPTUSeWyMH6e4CvTFvPE5Fs6Z8hvFITGyr0dtukHzkI84oviVLxhM1xMxrMAy1db"
|
||||
"w==",
|
||||
uint64_t{0x2599f4f905115869}},
|
||||
{"FvyQ00+j7nmYZVQ8hI1Edxd0AWplhTfWuFGiu34AK5X8u2hLX1bE97sZM0CmeLe+"
|
||||
"7LgoUT1fJ/axybE=",
|
||||
uint64_t{0xd8256e5444d21e53}},
|
||||
{"L8ncxMaYLBH3g9buPu8hfpWZNlOF7nvWLNv9IozH07uQsIBWSKxoPy8+"
|
||||
"LW4tTuzC6CIWbRGRRD1sQV/4",
|
||||
uint64_t{0xf664a91333fb8dfd}},
|
||||
{"CDK0meI07yrgV2kQlZZ+"
|
||||
"wuVqhc2NmzqeLH7bmcA6kchsRWFPeVF5Wqjjaj556ABeUoUr3yBmfU3kWOakkg==",
|
||||
uint64_t{0x9625b859be372cd1}},
|
||||
{"d23/vc5ONh/"
|
||||
"HkMiq+gYk4gaCNYyuFKwUkvn46t+dfVcKfBTYykr4kdvAPNXGYLjM4u1YkAEFpJP+"
|
||||
"nX7eOvs=",
|
||||
uint64_t{0x7b99940782e29898}},
|
||||
{"NUR3SRxBkxTSbtQORJpu/GdR6b/h6sSGfsMj/KFd99ahbh+9r7LSgSGmkGVB/"
|
||||
"mGoT0pnMTQst7Lv2q6QN6Vm",
|
||||
uint64_t{0x4fe12fa5383b51a8}},
|
||||
{"2BOFlcI3Z0RYDtS9T9Ie9yJoXlOdigpPeeT+CRujb/"
|
||||
"O39Ih5LPC9hP6RQk1kYESGyaLZZi3jtabHs7DiVx/VDg==",
|
||||
uint64_t{0xe2ccb09ac0f5b4b6}},
|
||||
{"FF2HQE1FxEvWBpg6Z9zAMH+Zlqx8S1JD/"
|
||||
"wIlViL6ZDZY63alMDrxB0GJQahmAtjlm26RGLnjW7jmgQ4Ie3I+014=",
|
||||
uint64_t{0x7d0a37adbd7b753b}},
|
||||
{"tHmO7mqVL/PX11nZrz50Hc+M17Poj5lpnqHkEN+4bpMx/"
|
||||
"YGbkrGOaYjoQjgmt1X2QyypK7xClFrjeWrCMdlVYtbW",
|
||||
uint64_t{0xd3ae96ef9f7185f2}},
|
||||
{"/WiHi9IQcxRImsudkA/KOTqGe8/"
|
||||
"gXkhKIHkjddv5S9hi02M049dIK3EUyAEjkjpdGLUs+BN0QzPtZqjIYPOgwsYE9g==",
|
||||
uint64_t{0x4fb88ea63f79a0d8}},
|
||||
{"qds+1ExSnU11L4fTSDz/QE90g4Jh6ioqSh3KDOTOAo2pQGL1k/"
|
||||
"9CCC7J23YF27dUTzrWsCQA2m4epXoCc3yPHb3xElA=",
|
||||
uint64_t{0xed564e259bb5ebe9}},
|
||||
{"8FVYHx40lSQPTHheh08Oq0/"
|
||||
"pGm2OlG8BEf8ezvAxHuGGdgCkqpXIueJBF2mQJhTfDy5NncO8ntS7vaKs7sCNdDaNGOEi",
|
||||
uint64_t{0x3e3256b60c428000}},
|
||||
{"4ZoEIrJtstiCkeew3oRzmyJHVt/pAs2pj0HgHFrBPztbQ10NsQ/"
|
||||
"lM6DM439QVxpznnBSiHMgMQJhER+70l72LqFTO1JiIQ==",
|
||||
uint64_t{0xfb05bad59ec8705}},
|
||||
{"hQPtaYI+wJyxXgwD5n8jGIKFKaFA/"
|
||||
"P83KqCKZfPthnjwdOFysqEOYwAaZuaaiv4cDyi9TyS8hk5cEbNP/jrI7q6pYGBLbsM=",
|
||||
uint64_t{0xafdc251dbf97b5f8}},
|
||||
{"S4gpMSKzMD7CWPsSfLeYyhSpfWOntyuVZdX1xSBjiGvsspwOZcxNKCRIOqAA0moUfOh3I5+"
|
||||
"juQV4rsqYElMD/gWfDGpsWZKQ",
|
||||
uint64_t{0x10ec9c92ddb5dcbc}},
|
||||
{"oswxop+"
|
||||
"bthuDLT4j0PcoSKby4LhF47ZKg8K17xxHf74UsGCzTBbOz0MM8hQEGlyqDT1iUiAYnaPaUp"
|
||||
"L2mRK0rcIUYA4qLt5uOw==",
|
||||
uint64_t{0x9a767d5822c7dac4}},
|
||||
{"0II/"
|
||||
"697p+"
|
||||
"BtLSjxj5989OXI004TogEb94VUnDzOVSgMXie72cuYRvTFNIBgtXlKfkiUjeqVpd4a+"
|
||||
"n5bxNOD1TGrjQtzKU5r7obo=",
|
||||
uint64_t{0xee46254080d6e2db}},
|
||||
{"E84YZW2qipAlMPmctrg7TKlwLZ68l4L+c0xRDUfyyFrA4MAti0q9sHq3TDFviH0Y+"
|
||||
"Kq3tEE5srWFA8LM9oomtmvm5PYxoaarWPLc",
|
||||
uint64_t{0xbbb669588d8bf398}},
|
||||
{"x3pa4HIElyZG0Nj7Vdy9IdJIR4izLmypXw5PCmZB5y68QQ4uRaVVi3UthsoJROvbjDJkP2D"
|
||||
"Q6L/eN8pFeLFzNPKBYzcmuMOb5Ull7w==",
|
||||
uint64_t{0xdc2afaa529beef44}},
|
||||
{"jVDKGYIuWOP/"
|
||||
"QKLdd2wi8B2VJA8Wh0c8PwrXJVM8FOGM3voPDVPyDJOU6QsBDPseoR8uuKd19OZ/"
|
||||
"zAvSCB+zlf6upAsBlheUKgCfKww=",
|
||||
uint64_t{0xf1f67391d45013a8}},
|
||||
{"mkquunhmYe1aR2wmUz4vcvLEcKBoe6H+kjUok9VUn2+eTSkWs4oDDtJvNCWtY5efJwg/"
|
||||
"j4PgjRYWtqnrCkhaqJaEvkkOwVfgMIwF3e+d",
|
||||
uint64_t{0x16fce2b8c65a3429}},
|
||||
{"fRelvKYonTQ+s+rnnvQw+JzGfFoPixtna0vzcSjiDqX5s2Kg2//"
|
||||
"UGrK+AVCyMUhO98WoB1DDbrsOYSw2QzrcPe0+3ck9sePvb+Q/IRaHbw==",
|
||||
uint64_t{0xf4b096699f49fe67}},
|
||||
{"DUwXFJzagljo44QeJ7/"
|
||||
"6ZKw4QXV18lhkYT2jglMr8WB3CHUU4vdsytvw6AKv42ZcG6fRkZkq9fpnmXy6xG0aO3WPT1"
|
||||
"eHuyFirAlkW+zKtwg=",
|
||||
uint64_t{0xca584c4bc8198682}},
|
||||
{"cYmZCrOOBBongNTr7e4nYn52uQUy2mfe48s50JXx2AZ6cRAt/"
|
||||
"xRHJ5QbEoEJOeOHsJyM4nbzwFm++SlT6gFZZHJpkXJ92JkR86uS/eV1hJUR",
|
||||
uint64_t{0xed269fc3818b6aad}},
|
||||
{"EXeHBDfhwzAKFhsMcH9+2RHwV+mJaN01+9oacF6vgm8mCXRd6jeN9U2oAb0of5c5cO4i+"
|
||||
"Vb/LlHZSMI490SnHU0bejhSCC2gsC5d2K30ER3iNA==",
|
||||
uint64_t{0x33f253cbb8fe66a8}},
|
||||
{"FzkzRYoNjkxFhZDso94IHRZaJUP61nFYrh5MwDwv9FNoJ5jyNCY/"
|
||||
"eazPZk+tbmzDyJIGw2h3GxaWZ9bSlsol/vK98SbkMKCQ/wbfrXRLcDzdd/8=",
|
||||
uint64_t{0xd0b76b2c1523d99c}},
|
||||
{"Re4aXISCMlYY/XsX7zkIFR04ta03u4zkL9dVbLXMa/q6hlY/CImVIIYRN3VKP4pnd0AUr/"
|
||||
"ugkyt36JcstAInb4h9rpAGQ7GMVOgBniiMBZ/MGU7H",
|
||||
uint64_t{0xfd28f0811a2a237f}},
|
||||
{"ueLyMcqJXX+MhO4UApylCN9WlTQ+"
|
||||
"ltJmItgG7vFUtqs2qNwBMjmAvr5u0sAKd8jpzV0dDPTwchbIeAW5zbtkA2NABJV6hFM48ib"
|
||||
"4/J3A5mseA3cS8w==",
|
||||
uint64_t{0x6261fb136482e84}},
|
||||
{"6Si7Yi11L+jZMkwaN+GUuzXMrlvEqviEkGOilNq0h8TdQyYKuFXzkYc/"
|
||||
"q74gP3pVCyiwz9KpVGMM9vfnq36riMHRknkmhQutxLZs5fbmOgEO69HglCU=",
|
||||
uint64_t{0x458efc750bca7c3a}},
|
||||
{"Q6AbOofGuTJOegPh9Clm/"
|
||||
"9crtUMQqylKrTc1fhfJo1tqvpXxhU4k08kntL1RG7woRnFrVh2UoMrL1kjin+s9CanT+"
|
||||
"y4hHwLqRranl9FjvxfVKm3yvg68",
|
||||
uint64_t{0xa7e69ff84e5e7c27}},
|
||||
{"ieQEbIPvqY2YfIjHnqfJiO1/MIVRk0RoaG/WWi3kFrfIGiNLCczYoklgaecHMm/"
|
||||
"1sZ96AjO+a5stQfZbJQwS7Sc1ODABEdJKcTsxeW2hbh9A6CFzpowP1A==",
|
||||
uint64_t{0x3c59bfd0c29efe9e}},
|
||||
{"zQUv8hFB3zh2GGl3KTvCmnfzE+"
|
||||
"SUgQPVaSVIELFX5H9cE3FuVFGmymkPQZJLAyzC90Cmi8GqYCvPqTuAAB//"
|
||||
"XTJxy4bCcVArgZG9zJXpjowpNBfr3ngWrSE=",
|
||||
uint64_t{0x10befacc6afd298d}},
|
||||
{"US4hcC1+op5JKGC7eIs8CUgInjKWKlvKQkapulxW262E/"
|
||||
"B2ye79QxOexf188u2mFwwe3WTISJHRZzS61IwljqAWAWoBAqkUnW8SHmIDwHUP31J0p5sGd"
|
||||
"P47L",
|
||||
uint64_t{0x41d5320b0a38efa7}},
|
||||
{"9bHUWFna2LNaGF6fQLlkx1Hkt24nrkLE2CmFdWgTQV3FFbUe747SSqYw6ebpTa07MWSpWRP"
|
||||
"sHesVo2B9tqHbe7eQmqYebPDFnNqrhSdZwFm9arLQVs+7a3Ic6A==",
|
||||
uint64_t{0x58db1c7450fe17f3}},
|
||||
{"Kb3DpHRUPhtyqgs3RuXjzA08jGb59hjKTOeFt1qhoINfYyfTt2buKhD6YVffRCPsgK9SeqZ"
|
||||
"qRPJSyaqsa0ovyq1WnWW8jI/NhvAkZTVHUrX2pC+cD3OPYT05Dag=",
|
||||
uint64_t{0x6098c055a335b7a6}},
|
||||
{"gzxyMJIPlU+bJBwhFUCHSofZ/"
|
||||
"319LxqMoqnt3+L6h2U2+ZXJCSsYpE80xmR0Ta77Jq54o92SMH87HV8dGOaCTuAYF+"
|
||||
"lDL42SY1P316Cl0sZTS2ow3ZqwGbcPNs/1",
|
||||
uint64_t{0x1bbacec67845a801}},
|
||||
{"uR7V0TW+FGVMpsifnaBAQ3IGlr1wx5sKd7TChuqRe6OvUXTlD4hKWy8S+"
|
||||
"8yyOw8lQabism19vOQxfmocEOW/"
|
||||
"vzY0pEa87qHrAZy4s9fH2Bltu8vaOIe+agYohhYORQ==",
|
||||
uint64_t{0xc419cfc7442190}},
|
||||
{"1UR5eoo2aCwhacjZHaCh9bkOsITp6QunUxHQ2SfeHv0imHetzt/"
|
||||
"Z70mhyWZBalv6eAx+YfWKCUib2SHDtz/"
|
||||
"A2dc3hqUWX5VfAV7FQsghPUAtu6IiRatq4YSLpDvKZBQ=",
|
||||
uint64_t{0xc95e510d94ba270c}},
|
||||
{"opubR7H63BH7OtY+Avd7QyQ25UZ8kLBdFDsBTwZlY6gA/"
|
||||
"u+x+"
|
||||
"czC9AaZMgmQrUy15DH7YMGsvdXnviTtI4eVI4aF1H9Rl3NXMKZgwFOsdTfdcZeeHVRzBBKX"
|
||||
"8jUfh1il",
|
||||
uint64_t{0xff1ae05c98089c3f}},
|
||||
{"DC0kXcSXtfQ9FbSRwirIn5tgPri0sbzHSa78aDZVDUKCMaBGyFU6BmrulywYX8yzvwprdLs"
|
||||
"oOwTWN2wMjHlPDqrvVHNEjnmufRDblW+nSS+xtKNs3N5xsxXdv6JXDrAB/Q==",
|
||||
uint64_t{0x90c02b8dceced493}},
|
||||
{"BXRBk+3wEP3Lpm1y75wjoz+PgB0AMzLe8tQ1AYU2/"
|
||||
"oqrQB2YMC6W+9QDbcOfkGbeH+b7IBkt/"
|
||||
"gwCMw2HaQsRFEsurXtcQ3YwRuPz5XNaw5NAvrNa67Fm7eRzdE1+hWLKtA8=",
|
||||
uint64_t{0x9f8a76697ab1aa36}},
|
||||
{"RRBSvEGYnzR9E45Aps/+WSnpCo/X7gJLO4DRnUqFrJCV/kzWlusLE/"
|
||||
"6ZU6RoUf2ROwcgEvUiXTGjLs7ts3t9SXnJHxC1KiOzxHdYLMhVvgNd3hVSAXODpKFSkVXND"
|
||||
"55G2L1W",
|
||||
uint64_t{0x6ba1bf3d811a531d}},
|
||||
{"jeh6Qazxmdi57pa9S3XSnnZFIRrnc6s8QLrah5OX3SB/V2ErSPoEAumavzQPkdKF1/"
|
||||
"SfvmdL+qgF1C+Yawy562QaFqwVGq7+tW0yxP8FStb56ZRgNI4IOmI30s1Ei7iops9Uuw==",
|
||||
uint64_t{0x6a418974109c67b4}},
|
||||
{"6QO5nnDrY2/"
|
||||
"wrUXpltlKy2dSBcmK15fOY092CR7KxAjNfaY+"
|
||||
"aAmtWbbzQk3MjBg03x39afSUN1fkrWACdyQKRaGxgwq6MGNxI6W+8DLWJBHzIXrntrE/"
|
||||
"ml6fnNXEpxplWJ1vEs4=",
|
||||
uint64_t{0x8472f1c2b3d230a3}},
|
||||
{"0oPxeEHhqhcFuwonNfLd5jF3RNATGZS6NPoS0WklnzyokbTqcl4BeBkMn07+fDQv83j/"
|
||||
"BpGUwcWO05f3+DYzocfnizpFjLJemFGsls3gxcBYxcbqWYev51tG3lN9EvRE+X9+Pwww",
|
||||
uint64_t{0x5e06068f884e73a7}},
|
||||
{"naSBSjtOKgAOg8XVbR5cHAW3Y+QL4Pb/JO9/"
|
||||
"oy6L08wvVRZqo0BrssMwhzBP401Um7A4ppAupbQeJFdMrysY34AuSSNvtNUy5VxjNECwiNt"
|
||||
"gwYHw7yakDUv8WvonctmnoSPKENegQg==",
|
||||
uint64_t{0x55290b1a8f170f59}},
|
||||
{"vPyl8DxVeRe1OpilKb9KNwpGkQRtA94UpAHetNh+"
|
||||
"95V7nIW38v7PpzhnTWIml5kw3So1Si0TXtIUPIbsu32BNhoH7QwFvLM+"
|
||||
"JACgSpc5e3RjsL6Qwxxi11npwxRmRUqATDeMUfRAjxg=",
|
||||
uint64_t{0x5501cfd83dfe706a}},
|
||||
{"QC9i2GjdTMuNC1xQJ74ngKfrlA4w3o58FhvNCltdIpuMhHP1YsDA78scQPLbZ3OCUgeQguY"
|
||||
"f/vw6zAaVKSgwtaykqg5ka/4vhz4hYqWU5ficdXqClHl+zkWEY26slCNYOM5nnDlly8Cj",
|
||||
uint64_t{0xe43ed13d13a66990}},
|
||||
{"7CNIgQhAHX27nxI0HeB5oUTnTdgKpRDYDKwRcXfSFGP1XeT9nQF6WKCMjL1tBV6x7KuJ91G"
|
||||
"Zz11F4c+8s+MfqEAEpd4FHzamrMNjGcjCyrVtU6y+7HscMVzr7Q/"
|
||||
"ODLcPEFztFnwjvCjmHw==",
|
||||
uint64_t{0xdf43bc375cf5283f}},
|
||||
{"Qa/hC2RPXhANSospe+gUaPfjdK/yhQvfm4cCV6/pdvCYWPv8p1kMtKOX3h5/"
|
||||
"8oZ31fsmx4Axphu5qXJokuhZKkBUJueuMpxRyXpwSWz2wELx5glxF7CM0Fn+"
|
||||
"OevnkhUn5jsPlG2r5jYlVn8=",
|
||||
uint64_t{0x8112b806d288d7b5}},
|
||||
{"kUw/0z4l3a89jTwN5jpG0SHY5km/"
|
||||
"IVhTjgM5xCiPRLncg40aqWrJ5vcF891AOq5hEpSq0bUCJUMFXgct7kvnys905HjerV7Vs1G"
|
||||
"y84tgVJ70/2+pAZTsB/PzNOE/G6sOj4+GbTzkQu819OLB",
|
||||
uint64_t{0xd52a18abb001cb46}},
|
||||
{"VDdfSDbO8Tdj3T5W0XM3EI7iHh5xpIutiM6dvcJ/fhe23V/srFEkDy5iZf/"
|
||||
"VnA9kfi2C79ENnFnbOReeuZW1b3MUXB9lgC6U4pOTuC+"
|
||||
"jHK3Qnpyiqzj7h3ISJSuo2pob7vY6VHZo6Fn7exEqHg==",
|
||||
uint64_t{0xe12b76a2433a1236}},
|
||||
{"Ldfvy3ORdquM/R2fIkhH/ONi69mcP1AEJ6n/"
|
||||
"oropwecAsLJzQSgezSY8bEiEs0VnFTBBsW+RtZY6tDj03fnb3amNUOq1b7jbqyQkL9hpl+"
|
||||
"2Z2J8IaVSeownWl+bQcsR5/xRktIMckC5AtF4YHfU=",
|
||||
uint64_t{0x175bf7319cf1fa00}},
|
||||
{"BrbNpb42+"
|
||||
"VzZAjJw6QLirXzhweCVRfwlczzZ0VX2xluskwBqyfnGovz5EuX79JJ31VNXa5hTkAyQat3l"
|
||||
"YKRADTdAdwE5PqM1N7YaMqqsqoAAAeuYVXuk5eWCykYmClNdSspegwgCuT+403JigBzi",
|
||||
uint64_t{0xd63d57b3f67525ae}},
|
||||
{"gB3NGHJJvVcuPyF0ZSvHwnWSIfmaI7La24VMPQVoIIWF7Z74NltPZZpx2f+cocESM+"
|
||||
"ILzQW9p+BC8x5IWz7N4Str2WLGKMdgmaBfNkEhSHQDU0IJEOnpUt0HmjhFaBlx0/"
|
||||
"LTmhua+rQ6Wup8ezLwfg==",
|
||||
uint64_t{0x933faea858832b73}},
|
||||
{"hTKHlRxx6Pl4gjG+6ksvvj0CWFicUg3WrPdSJypDpq91LUWRni2KF6+"
|
||||
"81ZoHBFhEBrCdogKqeK+hy9bLDnx7g6rAFUjtn1+cWzQ2YjiOpz4+"
|
||||
"ROBB7lnwjyTGWzJD1rXtlso1g2qVH8XJVigC5M9AIxM=",
|
||||
uint64_t{0x53d061e5f8e7c04f}},
|
||||
{"IWQBelSQnhrr0F3BhUpXUIDauhX6f95Qp+A0diFXiUK7irwPG1oqBiqHyK/SH/"
|
||||
"9S+"
|
||||
"rln9DlFROAmeFdH0OCJi2tFm4afxYzJTFR4HnR4cG4x12JqHaZLQx6iiu6CE3rtWBVz99oA"
|
||||
"wCZUOEXIsLU24o2Y",
|
||||
uint64_t{0xdb4124556dd515e0}},
|
||||
{"TKo+l+"
|
||||
"1dOXdLvIrFqeLaHdm0HZnbcdEgOoLVcGRiCbAMR0j5pIFw8D36tefckAS1RCFOH5IgP8yiF"
|
||||
"T0Gd0a2hI3+"
|
||||
"fTKA7iK96NekxWeoeqzJyctc6QsoiyBlkZerRxs5RplrxoeNg29kKDTM0K94mnhD9g==",
|
||||
uint64_t{0x4fb31a0dd681ee71}},
|
||||
{"YU4e7G6EfQYvxCFoCrrT0EFgVLHFfOWRTJQJ5gxM3G2b+"
|
||||
"1kJf9YPrpsxF6Xr6nYtS8reEEbDoZJYqnlk9lXSkVArm88Cqn6d25VCx3+"
|
||||
"49MqC0trIlXtb7SXUUhwpJK16T0hJUfPH7s5cMZXc6YmmbFuBNPE=",
|
||||
uint64_t{0x27cc72eefa138e4c}},
|
||||
{"/I/"
|
||||
"eImMwPo1U6wekNFD1Jxjk9XQVi1D+"
|
||||
"FPdqcHifYXQuP5aScNQfxMAmaPR2XhuOQhADV5tTVbBKwCDCX4E3jcDNHzCiPvViZF1W27t"
|
||||
"xaf2BbFQdwKrNCmrtzcluBFYu0XZfc7RU1RmxK/RtnF1qHsq/O4pp",
|
||||
uint64_t{0x44bc2dfba4bd3ced}},
|
||||
{"CJTT9WGcY2XykTdo8KodRIA29qsqY0iHzWZRjKHb9alwyJ7RZAE3V5Juv4MY3MeYEr1EPCC"
|
||||
"MxO7yFXqT8XA8YTjaMp3bafRt17Pw8JC4iKJ1zN+WWKOESrj+"
|
||||
"3aluGQqn8z1EzqY4PH7rLG575PYeWsP98BugdA==",
|
||||
uint64_t{0x242da1e3a439bed8}},
|
||||
{"ZlhyQwLhXQyIUEnMH/"
|
||||
"AEW27vh9xrbNKJxpWGtrEmKhd+nFqAfbeNBQjW0SfG1YI0xQkQMHXjuTt4P/"
|
||||
"EpZRtA47ibZDVS8TtaxwyBjuIDwqcN09eCtpC+Ls+"
|
||||
"vWDTLmBeDM3u4hmzz4DQAYsLiZYSJcldg9Q3wszw=",
|
||||
uint64_t{0xdc559c746e35c139}},
|
||||
{"v2KU8y0sCrBghmnm8lzGJlwo6D6ObccAxCf10heoDtYLosk4ztTpLlpSFEyu23MLA1tJkcg"
|
||||
"Rko04h19QMG0mOw/"
|
||||
"wc93EXAweriBqXfvdaP85sZABwiKO+6rtS9pacRVpYYhHJeVTQ5NzrvBvi1huxAr+"
|
||||
"xswhVMfL",
|
||||
uint64_t{0xd0b0350275b9989}},
|
||||
{"QhKlnIS6BuVCTQsnoE67E/"
|
||||
"yrgogE8EwO7xLaEGei26m0gEU4OksefJgppDh3X0x0Cs78Dr9IHK5b977CmZlrTRmwhlP8p"
|
||||
"M+UzXPNRNIZuN3ntOum/QhUWP8SGpirheXENWsXMQ/"
|
||||
"nxtxakyEtrNkKk471Oov9juP8oQ==",
|
||||
uint64_t{0xb04489e41d17730c}},
|
||||
{"/ZRMgnoRt+Uo6fUPr9FqQvKX7syhgVqWu+"
|
||||
"WUSsiQ68UlN0efSP6Eced5gJZL6tg9gcYJIkhjuQNITU0Q3TjVAnAcobgbJikCn6qZ6pRxK"
|
||||
"BY4MTiAlfGD3T7R7hwJwx554MAy++Zb/YUFlnCaCJiwQMnowF7aQzwYFCo=",
|
||||
uint64_t{0x2217285eb4572156}},
|
||||
{"NB7tU5fNE8nI+SXGfipc7sRkhnSkUF1krjeo6k+8FITaAtdyz+"
|
||||
"o7mONgXmGLulBPH9bEwyYhKNVY0L+njNQrZ9YC2aXsFD3PdZsxAFaBT3VXEzh+"
|
||||
"NGBTjDASNL3mXyS8Yv1iThGfHoY7T4aR0NYGJ+k+pR6f+KrPC96M",
|
||||
uint64_t{0x12c2e8e68aede73b}},
|
||||
{"8T6wrqCtEO6/rwxF6lvMeyuigVOLwPipX/FULvwyu+1wa5sQGav/"
|
||||
"2FsLHUVn6cGSi0LlFwLewGHPFJDLR0u4t7ZUyM//"
|
||||
"x6da0sWgOa5hzDqjsVGmjxEHXiaXKW3i4iSZNuxoNbMQkIbVML+"
|
||||
"DkYu9ND0O2swg4itGeVSzXA==",
|
||||
uint64_t{0x4d612125bdc4fd00}},
|
||||
{"Ntf1bMRdondtMv1CYr3G80iDJ4WSAlKy5H34XdGruQiCrnRGDBa+"
|
||||
"eUi7vKp4gp3BBcVGl8eYSasVQQjn7MLvb3BjtXx6c/"
|
||||
"bCL7JtpzQKaDnPr9GWRxpBXVxKREgMM7d8lm35EODv0w+"
|
||||
"hQLfVSh8OGs7fsBb68nNWPLeeSOo=",
|
||||
uint64_t{0x81826b553954464e}},
|
||||
{"VsSAw72Ro6xks02kaiLuiTEIWBC5bgqr4WDnmP8vglXzAhixk7td926rm9jNimL+"
|
||||
"kroPSygZ9gl63aF5DCPOACXmsbmhDrAQuUzoh9ZKhWgElLQsrqo1KIjWoZT5b5QfVUXY9lS"
|
||||
"IBg3U75SqORoTPq7HalxxoIT5diWOcJQi",
|
||||
uint64_t{0xc2e5d345dc0ddd2d}},
|
||||
{"j+loZ+C87+"
|
||||
"bJxNVebg94gU0mSLeDulcHs84tQT7BZM2rzDSLiCNxUedHr1ZWJ9ejTiBa0dqy2I2ABc++"
|
||||
"xzOLcv+//YfibtjKtYggC6/3rv0XCc7xu6d/"
|
||||
"O6xO+XOBhOWAQ+IHJVHf7wZnDxIXB8AUHsnjEISKj7823biqXjyP3g==",
|
||||
uint64_t{0x3da6830a9e32631e}},
|
||||
{"f3LlpcPElMkspNtDq5xXyWU62erEaKn7RWKlo540gR6mZsNpK1czV/"
|
||||
"sOmqaq8XAQLEn68LKj6/"
|
||||
"cFkJukxRzCa4OF1a7cCAXYFp9+wZDu0bw4y63qbpjhdCl8GO6Z2lkcXy7KOzbPE01ukg7+"
|
||||
"gN+7uKpoohgAhIwpAKQXmX5xtd0=",
|
||||
uint64_t{0xc9ae5c8759b4877a}},
|
||||
};
|
||||
|
||||
#if defined(ABSL_IS_BIG_ENDIAN)
|
||||
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
|
||||
0x4c34aacf38f6eee4, 0x88b1366815e50b88, 0x1a36bd0c6150fb9c,
|
||||
0xa783aba8a67366c7, 0x5e4a92123ae874f2, 0x0cc9ecf27067ee9a,
|
||||
0xbe77aa94940527f9, 0x7ea5c12f2669fe31, 0xa33eed8737d946b9,
|
||||
0x310aec5b1340bb36, 0x354e400861c5d8ff, 0x15be98166adcf42f,
|
||||
0xc51910b62a90ae51, 0x539d47fc7fdf6a1f, 0x3ebba9daa46eef93,
|
||||
0xd96bcd3a9113c17f, 0xc78eaf6256ded15a, 0x98902ed321c2f0d9,
|
||||
0x75a4ac96414b954a, 0x2cb90e00a39e307b, 0x46539574626c3637,
|
||||
0x186ec89a2be3ff45, 0x972a3bf7531519d2, 0xa14df0d25922364b,
|
||||
0xa351e19d22752109, 0x08bd311d8fed4f82, 0xea2b52ddc6af54f9,
|
||||
0x5f20549941338336, 0xd43b07422dc2782e, 0x377c68e2acda4835,
|
||||
0x1b31a0a663b1d7b3, 0x7388ba5d68058a1a, 0xe382794ea816f032,
|
||||
0xd4c3fe7889276ee0, 0x2833030545582ea9, 0x554d32a55e55df32,
|
||||
0x8d6d33d7e17b424d, 0xe51a193d03ae1e34, 0xabb6a80835bd66b3,
|
||||
0x0e4ba5293f9ce9b7, 0x1ebd8642cb762cdf, 0xcb54b555850888ee,
|
||||
0x1e4195e4717c701f, 0x6235a13937f6532a, 0xd460960741e845c0,
|
||||
0x2a72168a2d6af7b1, 0x6be38fbbfc5b17de, 0x4ee97cffa0d0fb39,
|
||||
0xfdf1119ad5e71a55, 0x0dff7f66b3070727, 0x812d791d6ed62744,
|
||||
0x60962919074b70b8, 0x956fa5c7d6872547, 0xee892daa58aae597,
|
||||
0xeeda546e998ee369, 0x454481f5eb9b1fa8, 0x1054394634c98b1b,
|
||||
0x55bb425415f591fb, 0x9601fa97416232c4, 0xd7a18506519daad7,
|
||||
0x90935cb5de039acf, 0xe64054c5146ed359, 0xe5b323fb1e866c09,
|
||||
0x10a472555f5ba1bc, 0xe3c0cd57d26e0972, 0x7ca3db7c121da3e8,
|
||||
0x7004a89c800bb466, 0x865f69c1a1ff7f39, 0xbe0edd48f0cf2b99,
|
||||
0x10e5e4ba3cc400f5, 0xafc2b91a220eef50, 0x6f04a259289b24f1,
|
||||
0x2179a8070e880ef0, 0xd6a9a3d023a740c2, 0x96e6d7954755d9b8,
|
||||
0xc8e4bddecce5af9f, 0x93941f0fbc724c92, 0xbef5fb15bf76a479,
|
||||
0x534dca8f5da86529, 0x70789790feec116b, 0x2a296e167eea1fe9,
|
||||
0x54cb1efd2a3ec7ea, 0x357b43897dfeb9f7, 0xd1eda89bc7ff89d3,
|
||||
0x434f2e10cbb83c98, 0xeec4cdac46ca69ce, 0xd46aafd52a303206,
|
||||
0x4bf05968ff50a5c9, 0x71c533747a6292df, 0xa40bd0d16a36118c,
|
||||
0x597b4ee310c395ab, 0xc5b3e3e386172583, 0x12ca0b32284e6c70,
|
||||
0xb48995fadcf35630, 0x0646368454cd217d, 0xa21c168e40d765b5,
|
||||
0x4260d3811337da30, 0xb72728a01cff78e4, 0x8586920947f4756f,
|
||||
0xc21e5f853cae7dc1, 0xf08c9533be9de285, 0x72df06653b4256d6,
|
||||
0xf7b7f937f8db1779, 0x976db27dd0418127, 0x9ce863b7bc3f9e00,
|
||||
0xebb679854fcf3a0a, 0x2ccebabbcf1afa99, 0x44201d6be451dac5,
|
||||
0xb4af71c0e9a537d1, 0xad8fe9bb33ed2681, 0xcb30128bb68df43b,
|
||||
0x154d8328903e8d07, 0x5844276dabeabdff, 0xd99017d7d36d930b,
|
||||
0xabb0b4774fb261ca, 0x0a43f075d62e67e0, 0x8df7b371355ada6b,
|
||||
0xf4c7a40d06513dcf, 0x257a3615955a0372, 0x987ac410bba74c06,
|
||||
0xa011a46f25a632a2, 0xa14384b963ddd995, 0xf51b6b8cf9d50ba7,
|
||||
0x3acdb91ee3abf18d, 0x34e799be08920e8c, 0x8766748a31304b36,
|
||||
0x0aa239d5d0092f2e, 0xadf473ed26628594, 0xc4094b798eb4b79b,
|
||||
0xe04ee5f33cd130f4, 0x85045d098c341d46, 0xf936cdf115a890ec,
|
||||
0x51d137b6d8d2eb4f, 0xd10738bb2fccc1ef,
|
||||
};
|
||||
#else
|
||||
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
|
||||
0x4c34aacf38f6eee4, 0x88b1366815e50b88, 0x1a36bd0c6150fb9c,
|
||||
0xa783aba8a67366c7, 0xbc89ebdc622314e4, 0x632bc3cfcc7544d8,
|
||||
0xbe77aa94940527f9, 0x7ea5c12f2669fe31, 0xa33eed8737d946b9,
|
||||
0x74d832ea11fd18ab, 0x49c0487486246cdc, 0x3fdd986c87ddb0a0,
|
||||
0xac3fa52a64d7c09a, 0xbff0e330196e7ed2, 0x8c8138d3ad7d3cce,
|
||||
0x968c7d4b48e93778, 0xa04c78d3a421f529, 0x8854bc9c3c3c0241,
|
||||
0xcccfcdf5a41113fe, 0xe6fc63dc543d984d, 0x00a39ff89e903c05,
|
||||
0xaf7e9da25f9a26f9, 0x6e269a13d01a43df, 0x846d2300ce2ecdf8,
|
||||
0xe7ea8c8f08478260, 0x9a2db0d62f6232f3, 0x6f66c761d168c59f,
|
||||
0x55f9feacaae82043, 0x518084043700f614, 0xb0c8cfc11bead99f,
|
||||
0xe4a68fdab6359d80, 0x97b17caa8f92236e, 0x96edf5e8363643dc,
|
||||
0x9b3fbcd8d5b254cd, 0x22a263621d9b3a8b, 0xde90bf6f81800a6d,
|
||||
0x1b51cae38c2e9513, 0x689215b3c414ef21, 0x064dc85afae8f557,
|
||||
0xa2f3a8b51f408378, 0x6907c197ec1f6a3b, 0xfe83a42ef5c1cf13,
|
||||
0x9b8b1d8f7a20cc13, 0x1f1681d52ca895d0, 0xd7b1670bf28e0f96,
|
||||
0xb32f20f82d8b038a, 0x6a61d030fb2f5253, 0x8eb2bb0bc29ebb39,
|
||||
0x144f36f7a9eef95c, 0xe77aa47d29808d8c, 0xf14d34c1fc568bad,
|
||||
0x9796dcd4383f3c73, 0xa2f685fc1be7225b, 0xf3791295b16068b1,
|
||||
0xb6b8f63424618948, 0x8ac4fd587045db19, 0x7e2aec2c34feb72e,
|
||||
0x72e135a6910ccbb1, 0x661ff16f3c904e6f, 0xdf92cf9d67ca092d,
|
||||
0x98a9953d79722eef, 0xe0649ed2181d1707, 0xcd8b8478636a297b,
|
||||
0x9516258709c8471b, 0xc703b675b51f4394, 0xdb740eae020139f3,
|
||||
0x57d1499ac4212ff2, 0x355cc03713d43825, 0x0e71ac9b8b1e101e,
|
||||
0x8029fa72258ff559, 0xa2159726b4c16a50, 0x04e61582fba43007,
|
||||
0xdab25af835be8cce, 0x13510b1b184705ee, 0xabdbc9e53666fdeb,
|
||||
0x94a788fcb8173cef, 0x750d5e031286e722, 0x02559e72f4f5b497,
|
||||
0x7d6e0e5996a646fa, 0x66e871b73b014132, 0x2ec170083f8b784f,
|
||||
0x34ac9540cfce3fd9, 0x75c5622c6aad1295, 0xf799a6bb2651acc1,
|
||||
0x8f6bcd3145bdc452, 0xddd9d326eb584a04, 0x5411af1e3532f8dc,
|
||||
0xeb34722f2ad0f509, 0x835bc952a82298cc, 0xeb3839ff60ea92ad,
|
||||
0x70bddf1bcdc8a4bc, 0x4bfb3ee86fcde525, 0xc7b3b93b81dfa386,
|
||||
0xe66db544d57997e8, 0xf68a1b83fd363187, 0xe9b99bec615b171b,
|
||||
0x093fba04d04ad28a, 0xba6117ed4231a303, 0x594bef25f9d4e206,
|
||||
0x0a8cba60578b8f67, 0x88f6c7ca10b06019, 0x32a74082aef17b08,
|
||||
0xe758222f971e22df, 0x4af14ff4a593e51e, 0xdba651e16cb09044,
|
||||
0x3f3ac837d181eaac, 0xa5589a3f89610c01, 0xd409a7c3a18d5643,
|
||||
0x8a89444f82962f26, 0x22eb62a13b9771b9, 0xd3a617615256ddd8,
|
||||
0x7089b990c4bba297, 0x7d752893783eac4f, 0x1f2fcbb79372c915,
|
||||
0x67a4446b17eb9839, 0x70d11df5cae46788, 0x52621e1780b47d0f,
|
||||
0xcf63b93a6e590ee6, 0xb6bc96b58ee064b8, 0x2587f8d635ca9c75,
|
||||
0xc6bddd62ec5e5d01, 0x957398ad3009cdb7, 0x05b6890b20bcd0d3,
|
||||
0xbe6e965ff837222e, 0x47383a87d2b04b1a, 0x7d42207e6d8d7950,
|
||||
0x7e981ed12a7f4aa3, 0xdebb05b30769441a, 0xaac5d86f4ff76c49,
|
||||
0x384f195ca3248331, 0xec4c4b855e909ca1, 0x6a7eeb5a657d73d5,
|
||||
0x9efbebe2fa9c2791, 0x19e7fa0546900c4d,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if UPDATE_GOLDEN
|
||||
(void)kGolden; // Silence warning.
|
||||
for (size_t i = 0; i < kNumGoldenOutputs; ++i) {
|
||||
std::string str;
|
||||
ASSERT_TRUE(absl::Base64Unescape(cases[i].base64_data, &str));
|
||||
uint64_t h = absl::hash_internal::LowLevelHash(str.data(), str.size(),
|
||||
cases[i].seed, kSalt);
|
||||
printf("0x%016" PRIx64 ", ", h);
|
||||
if (i % 3 == 2) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n\n\n");
|
||||
EXPECT_FALSE(true);
|
||||
#else
|
||||
for (size_t i = 0; i < kNumGoldenOutputs; ++i) {
|
||||
SCOPED_TRACE(::testing::Message()
|
||||
<< "i = " << i << "; input = " << cases[i].base64_data);
|
||||
std::string str;
|
||||
ASSERT_TRUE(absl::Base64Unescape(cases[i].base64_data, &str));
|
||||
EXPECT_EQ(absl::hash_internal::LowLevelHash(str.data(), str.size(),
|
||||
cases[i].seed, kSalt),
|
||||
kGolden[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "absl/hash/hash.h"
|
||||
|
||||
// Prints the hash of argv[1].
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2) return 1;
|
||||
printf("%zu\n", absl::Hash<int>{}(std::atoi(argv[1]))); // NOLINT
|
||||
}
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
// Copyright 2018 The Abseil Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_
|
||||
#define ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/hash/hash.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_join.h"
|
||||
|
||||
namespace absl {
|
||||
ABSL_NAMESPACE_BEGIN
|
||||
namespace hash_internal {
|
||||
|
||||
// SpyHashState is an implementation of the HashState API that simply
|
||||
// accumulates all input bytes in an internal buffer. This makes it useful
|
||||
// for testing AbslHashValue overloads (so long as they are templated on the
|
||||
// HashState parameter), since it can report the exact hash representation
|
||||
// that the AbslHashValue overload produces.
|
||||
//
|
||||
// Sample usage:
|
||||
// EXPECT_EQ(SpyHashState::combine(SpyHashState(), foo),
|
||||
// SpyHashState::combine(SpyHashState(), bar));
|
||||
template <typename T>
|
||||
class SpyHashStateImpl : public HashStateBase<SpyHashStateImpl<T>> {
|
||||
public:
|
||||
SpyHashStateImpl() : error_(std::make_shared<absl::optional<std::string>>()) {
|
||||
static_assert(std::is_void<T>::value, "");
|
||||
}
|
||||
|
||||
// Move-only
|
||||
SpyHashStateImpl(const SpyHashStateImpl&) = delete;
|
||||
SpyHashStateImpl& operator=(const SpyHashStateImpl&) = delete;
|
||||
|
||||
SpyHashStateImpl(SpyHashStateImpl&& other) noexcept {
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
SpyHashStateImpl& operator=(SpyHashStateImpl&& other) noexcept {
|
||||
hash_representation_ = std::move(other.hash_representation_);
|
||||
error_ = other.error_;
|
||||
moved_from_ = other.moved_from_;
|
||||
other.moved_from_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
SpyHashStateImpl(SpyHashStateImpl<U>&& other) { // NOLINT
|
||||
hash_representation_ = std::move(other.hash_representation_);
|
||||
error_ = other.error_;
|
||||
moved_from_ = other.moved_from_;
|
||||
other.moved_from_ = true;
|
||||
}
|
||||
|
||||
template <typename A, typename... Args>
|
||||
static SpyHashStateImpl combine(SpyHashStateImpl s, const A& a,
|
||||
const Args&... args) {
|
||||
// Pass an instance of SpyHashStateImpl<A> when trying to combine `A`. This
|
||||
// allows us to test that the user only uses this instance for combine calls
|
||||
// and does not call AbslHashValue directly.
|
||||
// See AbslHashValue implementation at the bottom.
|
||||
s = SpyHashStateImpl<A>::HashStateBase::combine(std::move(s), a);
|
||||
return SpyHashStateImpl::combine(std::move(s), args...);
|
||||
}
|
||||
static SpyHashStateImpl combine(SpyHashStateImpl s) {
|
||||
if (direct_absl_hash_value_error_) {
|
||||
*s.error_ = "AbslHashValue should not be invoked directly.";
|
||||
} else if (s.moved_from_) {
|
||||
*s.error_ = "Used moved-from instance of the hash state object.";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static void SetDirectAbslHashValueError() {
|
||||
direct_absl_hash_value_error_ = true;
|
||||
}
|
||||
|
||||
// Two SpyHashStateImpl objects are equal if they hold equal hash
|
||||
// representations.
|
||||
friend bool operator==(const SpyHashStateImpl& lhs,
|
||||
const SpyHashStateImpl& rhs) {
|
||||
return lhs.hash_representation_ == rhs.hash_representation_;
|
||||
}
|
||||
|
||||
friend bool operator!=(const SpyHashStateImpl& lhs,
|
||||
const SpyHashStateImpl& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
enum class CompareResult {
|
||||
kEqual,
|
||||
kASuffixB,
|
||||
kBSuffixA,
|
||||
kUnequal,
|
||||
};
|
||||
|
||||
static CompareResult Compare(const SpyHashStateImpl& a,
|
||||
const SpyHashStateImpl& b) {
|
||||
const std::string a_flat = absl::StrJoin(a.hash_representation_, "");
|
||||
const std::string b_flat = absl::StrJoin(b.hash_representation_, "");
|
||||
if (a_flat == b_flat) return CompareResult::kEqual;
|
||||
if (absl::EndsWith(a_flat, b_flat)) return CompareResult::kBSuffixA;
|
||||
if (absl::EndsWith(b_flat, a_flat)) return CompareResult::kASuffixB;
|
||||
return CompareResult::kUnequal;
|
||||
}
|
||||
|
||||
// operator<< prints the hash representation as a hex and ASCII dump, to
|
||||
// facilitate debugging.
|
||||
friend std::ostream& operator<<(std::ostream& out,
|
||||
const SpyHashStateImpl& hash_state) {
|
||||
out << "[\n";
|
||||
for (auto& s : hash_state.hash_representation_) {
|
||||
size_t offset = 0;
|
||||
for (char c : s) {
|
||||
if (offset % 16 == 0) {
|
||||
out << absl::StreamFormat("\n0x%04x: ", offset);
|
||||
}
|
||||
if (offset % 2 == 0) {
|
||||
out << " ";
|
||||
}
|
||||
out << absl::StreamFormat("%02x", c);
|
||||
++offset;
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
return out << "]";
|
||||
}
|
||||
|
||||
// The base case of the combine recursion, which writes raw bytes into the
|
||||
// internal buffer.
|
||||
static SpyHashStateImpl combine_contiguous(SpyHashStateImpl hash_state,
|
||||
const unsigned char* begin,
|
||||
size_t size) {
|
||||
const size_t large_chunk_stride = PiecewiseChunkSize();
|
||||
// Combining a large contiguous buffer must have the same effect as
|
||||
// doing it piecewise by the stride length, followed by the (possibly
|
||||
// empty) remainder.
|
||||
while (size > large_chunk_stride) {
|
||||
hash_state = SpyHashStateImpl::combine_contiguous(
|
||||
std::move(hash_state), begin, large_chunk_stride);
|
||||
begin += large_chunk_stride;
|
||||
size -= large_chunk_stride;
|
||||
}
|
||||
|
||||
if (size > 0) {
|
||||
hash_state.hash_representation_.emplace_back(
|
||||
reinterpret_cast<const char*>(begin), size);
|
||||
}
|
||||
return hash_state;
|
||||
}
|
||||
|
||||
using SpyHashStateImpl::HashStateBase::combine_contiguous;
|
||||
|
||||
template <typename CombinerT>
|
||||
static SpyHashStateImpl RunCombineUnordered(SpyHashStateImpl state,
|
||||
CombinerT combiner) {
|
||||
UnorderedCombinerCallback cb;
|
||||
|
||||
combiner(SpyHashStateImpl<void>{}, std::ref(cb));
|
||||
|
||||
std::sort(cb.element_hash_representations.begin(),
|
||||
cb.element_hash_representations.end());
|
||||
state.hash_representation_.insert(state.hash_representation_.end(),
|
||||
cb.element_hash_representations.begin(),
|
||||
cb.element_hash_representations.end());
|
||||
if (cb.error && cb.error->has_value()) {
|
||||
state.error_ = std::move(cb.error);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
absl::optional<std::string> error() const {
|
||||
if (moved_from_) {
|
||||
return "Returned a moved-from instance of the hash state object.";
|
||||
}
|
||||
return *error_;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename U>
|
||||
friend class SpyHashStateImpl;
|
||||
friend struct CombineRaw;
|
||||
|
||||
struct UnorderedCombinerCallback {
|
||||
std::vector<std::string> element_hash_representations;
|
||||
std::shared_ptr<absl::optional<std::string>> error;
|
||||
|
||||
// The inner spy can have a different type.
|
||||
template <typename U>
|
||||
void operator()(SpyHashStateImpl<U>& inner) {
|
||||
element_hash_representations.push_back(
|
||||
absl::StrJoin(inner.hash_representation_, ""));
|
||||
if (inner.error_->has_value()) {
|
||||
error = std::move(inner.error_);
|
||||
}
|
||||
inner = SpyHashStateImpl<void>{};
|
||||
}
|
||||
};
|
||||
|
||||
// Combines raw data from e.g. integrals/floats/pointers/etc.
|
||||
static SpyHashStateImpl combine_raw(SpyHashStateImpl state, uint64_t value) {
|
||||
const unsigned char* data = reinterpret_cast<const unsigned char*>(&value);
|
||||
return SpyHashStateImpl::combine_contiguous(std::move(state), data, 8);
|
||||
}
|
||||
|
||||
// This is true if SpyHashStateImpl<T> has been passed to a call of
|
||||
// AbslHashValue with the wrong type. This detects that the user called
|
||||
// AbslHashValue directly (because the hash state type does not match).
|
||||
static bool direct_absl_hash_value_error_;
|
||||
|
||||
std::vector<std::string> hash_representation_;
|
||||
// This is a shared_ptr because we want all instances of the particular
|
||||
// SpyHashState run to share the field. This way we can set the error for
|
||||
// use-after-move and all the copies will see it.
|
||||
std::shared_ptr<absl::optional<std::string>> error_;
|
||||
bool moved_from_ = false;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool SpyHashStateImpl<T>::direct_absl_hash_value_error_;
|
||||
|
||||
template <bool& B>
|
||||
struct OdrUse {
|
||||
constexpr OdrUse() {}
|
||||
bool& b = B;
|
||||
};
|
||||
|
||||
template <void (*)()>
|
||||
struct RunOnStartup {
|
||||
static bool run;
|
||||
static constexpr OdrUse<run> kOdrUse{};
|
||||
};
|
||||
|
||||
template <void (*f)()>
|
||||
bool RunOnStartup<f>::run = (f(), true);
|
||||
|
||||
template <
|
||||
typename T, typename U,
|
||||
// Only trigger for when (T != U),
|
||||
typename = absl::enable_if_t<!std::is_same<T, U>::value>,
|
||||
// This statement works in two ways:
|
||||
// - First, it instantiates RunOnStartup and forces the initialization of
|
||||
// `run`, which set the global variable.
|
||||
// - Second, it triggers a SFINAE error disabling the overload to prevent
|
||||
// compile time errors. If we didn't disable the overload we would get
|
||||
// ambiguous overload errors, which we don't want.
|
||||
int = RunOnStartup<SpyHashStateImpl<T>::SetDirectAbslHashValueError>::run>
|
||||
void AbslHashValue(SpyHashStateImpl<T>, const U&);
|
||||
|
||||
using SpyHashState = SpyHashStateImpl<void>;
|
||||
|
||||
} // namespace hash_internal
|
||||
ABSL_NAMESPACE_END
|
||||
} // namespace absl
|
||||
|
||||
#endif // ABSL_HASH_INTERNAL_SPY_HASH_STATE_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue