module
XXH3 familyXXH3 is a more recent hash algorithm featuring:
- Improved speed for both small and large inputs
- True 64-bit and 128-bit outputs
- SIMD acceleration
- Improved 32-bit viability
Speed analysis methodology is explained here:
https:/
Compared to XXH64, expect XXH3 to run approximately ~2x faster on large inputs and >3x faster on small ones, exact differences vary depending on platform.
XXH3's speed benefits greatly from SIMD and 64-bit arithmetic, but does not require it. Any 32-bit and 64-bit targets that can run XXH32 smoothly can run XXH3 at competitive speeds, even without vector support. Further details are explained in the implementation.
Optimized implementations are provided for AVX512, AVX2, SSE2, NEON, POWER8, ZVector and scalar targets. This can be controlled via the XXH_VECTOR macro.
XXH3 implementation is portable: it has a generic C90 formulation that can be compiled on any platform, all implementations generage exactly the same hash value on all platforms. Starting from v0.8.0, it's also labelled "stable", meaning that any future version will also generate the same hash value.
XXH3 offers 2 variants, _64bits and _128bits.
When only 64 bits are needed, prefer invoking the _64bits variant, as it reduces the amount of mixing, resulting in faster speed on small inputs. It's also generally simpler to manipulate a scalar return type than a struct.
The API supports one-shot hashing, streaming mode, and custom secrets.
Classes
- struct XXH128_hash_t
- The return value from 128-bit hashes.
- struct XXH128_canonical_t
Typedefs
- using XXH3_state_t = struct XXH3_state_s
- The state struct for the XXH3 streaming API.
Functions
- auto XXH3_64bits(const void* data, size_t len) -> XXH_PUBLIC_API XXH64_hash_t
- auto XXH3_64bits_withSeed(const void* data, size_t len, XXH64_hash_t seed) -> XXH_PUBLIC_API XXH64_hash_t
- auto XXH3_64bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize) -> XXH_PUBLIC_API XXH64_hash_t
-
auto XXH3_createState(void) -> XXH_PUBLIC_API XXH3_
state_ t* -
auto XXH3_freeState(XXH3_
state_ t* statePtr) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_copyState(XXH3_
state_ t* dst_state, const XXH3_ state_ t* src_state) -> XXH_PUBLIC_API void -
auto XXH3_64bits_reset(XXH3_
state_ t* statePtr) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_64bits_reset_withSeed(XXH3_
state_ t* statePtr, XXH64_hash_t seed) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_64bits_reset_withSecret(XXH3_
state_ t* statePtr, const void* secret, size_t secretSize) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_64bits_update(XXH3_
state_ t* statePtr, const void* input, size_t length) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_64bits_digest(const XXH3_
state_ t* statePtr) -> XXH_PUBLIC_API XXH64_hash_t -
auto XXH3_128bits(const void* data,
size_t len) -> XXH_PUBLIC_API XXH128_
hash_ t -
auto XXH3_128bits_withSeed(const void* data,
size_t len,
XXH64_hash_t seed) -> XXH_PUBLIC_API XXH128_
hash_ t -
auto XXH3_128bits_withSecret(const void* data,
size_t len,
const void* secret,
size_t secretSize) -> XXH_PUBLIC_API XXH128_
hash_ t -
auto XXH3_128bits_reset(XXH3_
state_ t* statePtr) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_128bits_reset_withSeed(XXH3_
state_ t* statePtr, XXH64_hash_t seed) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_128bits_reset_withSecret(XXH3_
state_ t* statePtr, const void* secret, size_t secretSize) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_128bits_update(XXH3_
state_ t* statePtr, const void* input, size_t length) -> XXH_PUBLIC_API XXH_errorcode -
auto XXH3_128bits_digest(const XXH3_
state_ t* statePtr) -> XXH_PUBLIC_API XXH128_ hash_ t -
auto XXH128_isEqual(XXH128_
hash_ t h1, XXH128_ hash_ t h2) -> XXH_PUBLIC_API int - auto XXH128_cmp(const void* h128_1, const void* h128_2) -> XXH_PUBLIC_API int
-
auto XXH128_canonicalFromHash(XXH128_
canonical_ t* dst, XXH128_ hash_ t hash) -> XXH_PUBLIC_API void -
auto XXH128_hashFromCanonical(const XXH128_
canonical_ t* src) -> XXH_PUBLIC_API XXH128_ hash_ t
Defines
- #define XXH3_SECRET_SIZE_MIN
Typedef documentation
typedef struct XXH3_state_s XXH3_state_t
#include <eckit/contrib/xxhash/xxhash.h>
The state struct for the XXH3 streaming API.
Function documentation
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* data,
size_t len)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data,
size_t len,
XXH64_hash_t seed)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data,
size_t len,
const void* secret,
size_t secretSize)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH3_ state_ t* XXH3_createState(void)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_ state_ t* statePtr)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API void XXH3_copyState(XXH3_ state_ t* dst_state,
const XXH3_ state_ t* src_state)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH3_ state_ t* statePtr)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_ state_ t* statePtr,
XXH64_hash_t seed)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_ state_ t* statePtr,
const void* secret,
size_t secretSize)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update(XXH3_ state_ t* statePtr,
const void* input,
size_t length)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest(const XXH3_ state_ t* statePtr)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH128_ hash_ t XXH3_128bits(const void* data,
size_t len)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH128_ hash_ t XXH3_128bits_withSeed(const void* data,
size_t len,
XXH64_hash_t seed)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH128_ hash_ t XXH3_128bits_withSecret(const void* data,
size_t len,
const void* secret,
size_t secretSize)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH3_ state_ t* statePtr)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH3_ state_ t* statePtr,
XXH64_hash_t seed)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH3_ state_ t* statePtr,
const void* secret,
size_t secretSize)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update(XXH3_ state_ t* statePtr,
const void* input,
size_t length)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH128_ hash_ t XXH3_128bits_digest(const XXH3_ state_ t* statePtr)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API int XXH128_isEqual(XXH128_ hash_ t h1,
XXH128_ hash_ t h2)
#include <eckit/contrib/xxhash/xxhash.h>
XXH128_h1
and h2
are equal, 0 if they are not.
XXH_PUBLIC_API int XXH128_cmp(const void* h128_1,
const void* h128_2)
#include <eckit/contrib/xxhash/xxhash.h>
This comparator is compatible with stdlib's qsort()
/bsearch()
.
return: >0 if *h128_1 > *h128_2 =0 if *h128_1 == *h128_2 <0 if *h128_1 < *h128_2
XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH128_ canonical_ t* dst,
XXH128_ hash_ t hash)
#include <eckit/contrib/xxhash/xxhash.h>
XXH_PUBLIC_API XXH128_ hash_ t XXH128_hashFromCanonical(const XXH128_ canonical_ t* src)
#include <eckit/contrib/xxhash/xxhash.h>
Define documentation
#define XXH3_SECRET_SIZE_MIN
#include <eckit/contrib/xxhash/xxhash.h>
The bare minimum size for a custom secret.