Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::BloomHash Class Reference

A 32-bit key hash for BloomFilter and CountingBloomFilter. More...

#include "donner/base/BloomFilter.h"

Public Member Functions

constexpr BloomHash (std::uint32_t value) noexcept
 Wraps a precomputed hash value.
constexpr std::uint32_t value () const noexcept
 Returns the hash value.

Static Public Member Functions

static constexpr BloomHash Of (std::string_view bytes, std::uint32_t salt) noexcept
 Hashes bytes under salt.

Friends

constexpr bool operator== (BloomHash lhs, BloomHash rhs) noexcept=default
 Equality operator.

Detailed Description

A 32-bit key hash for BloomFilter and CountingBloomFilter.

Compute it once per key with Of and reuse it for every insertion and probe.

The value is a pure function of the key bytes and the salt, identical on every platform and standard library, so tests and fuzzer corpora are reproducible.

Constructor & Destructor Documentation

◆ BloomHash()

donner::BloomHash::BloomHash ( std::uint32_t value)
inlineexplicitconstexprnoexcept

Wraps a precomputed hash value.

Parameters
valueHash value; a filter with 2^k slots probes bits 0 to k-1 and k to 2k-1.

Member Function Documentation

◆ Of()

constexpr BloomHash donner::BloomHash::Of ( std::string_view bytes,
std::uint32_t salt )
inlinestaticconstexprnoexcept

Hashes bytes under salt.

The hash is 32-bit FNV-1a over the salt's four bytes in little-endian order followed by bytes, then the MurmurHash3 fmix32 finalizer, so that every input bit affects the low bits the filters probe.

Parameters
bytesKey bytes; each byte is taken as an unsigned value.
saltKey kind, so that keys of different kinds with the same spelling (for example a tag name and a class name) hash differently.

The documentation for this class was generated from the following file: