Chronicle Software
-
net.openhft.hashing.LongHashFunctionis the primary façade for 64-bit hashes. It exposes factory methods for CityHash 1.1, FarmHash (NA and UO variants), MurmurHash3, xxHash, XXH3 (64-bit), wyHash v3, and MetroHash (LongHashFunction.java). -
net.openhft.hashing.LongTupleHashFunctionprovides multi-word hash results. It currently delivers 128-bit MurmurHash3 and XXH3 outputs and mirrors the single-word API with reusablelong[]buffers (LongTupleHashFunction.java). -
net.openhft.hashing.DualHashFunctionbridges tuple implementations back into theLongHashFunctioncontract, ensuring seeded XXH128 and similar algorithms can expose both 64-bit and 128-bit variants without duplicating logic (DualHashFunction.java).
-
All hashing flows rely on
net.openhft.hashing.Access<T>to read primitive values from arrays, direct buffers, off-heap memory, or custom structures.Access.byteOrder(input, desiredOrder)returns a view that matches the algorithm’s expected endianness (Access.java:273-308). -
Concrete strategies cover heap arrays (
UnsafeAccess.INSTANCE),ByteBuffer(ByteBufferAccess),CharSequencein native or explicit byte order (CharSequenceAccess), and compact Latin-1 backed strings (CompactLatin1CharSequenceAccess). -
UnsafeAccesswrapssun.misc.Unsafefor zero-copy reads, falling back to legacy helpers whengetByteorgetShortare absent (e.g., pre-Nougat Android) (UnsafeAccess.java:40-118). -
Reverse-order wrappers are generated automatically through
Access.newDefaultReverseAccess, allowing algorithms to treat every source as little-endian while still accepting big-endian buffers (Access.java:295-344).
-
Each upstream hash family lives in its own package-private class and exposes seed-aware factories back to the public façade.
-
CityAndFarmHash_1_1adapts CityHash64 1.1 plus FarmHash NA/UO variants, including the short-input specialisations from the original C++ sources. -
MurmurHash_3contains both 64-bit and 128-bit variants, reusingDualHashFunctionto provideLongHashFunctionandLongTupleHashFunctionaccessors. -
XxHashimplements XXH64 with the upstream prime constants and treats all inputs as little-endian viaAccess.byteOrder(XxHash.java). -
XXH3delivers XXH3 64-bit and 128-bit functions, including the FARSH-derived secret and block-stripe accumulation strategy (XXH3.java). -
WyHashports wyHash v3, including the 256-byte streaming loop and_wymummixing helper built onMaths.unsignedLongMulXorFold(WyHash.java). -
MetroHashimplements the metrohash64_2 variant using four-lane accumulation and deterministic finalisation (MetroHash.java).
-
-
net.openhft.hashing.Util.VALID_STRING_HASHselects the correctStringHashstrategy at JVM initialisation time by inspectingjava.vm.nameandjava.version, covering HotSpot, OpenJ9, Zing, and unknown VMs (Util.java:29-63). -
ModernHotSpotStringHash,ModernCompactStringHash, andHotSpotPrior7u6StringHashencode the memory layout differences between pre-compact, compact-string, and legacy HotSpot builds. When the VM cannot be recognised,UnknownJvmStringHashprovides a defensive fallback. -
Direct buffer hashing uses
sun.nio.ch.DirectBufferaddresses pulled viaLongHashFunction.hashBytes(ByteBuffer)andLongHashFunction.hashMemory(long, long);Util.getDirectBufferAddresscentralises the address extraction (Util.java:65-68).
-
net.openhft.hashing.Primitiveshouses byte-order normalisation helpers and unsigned conversions so algorithms can expect canonical little-endian operands even on big-endian hardware (Primitives.java). -
net.openhft.hashing.Mathsprovides low-level arithmetic helpers such asunsignedLongMulXorFoldused by wyHash and XXH3 for 128-bit cross-products (Maths.java). -
Tests under
src/test/java/net/openhft/hashingvalidate the API contract across arrays, primitives, buffers, and custom access strategies, and serve as reference snippets for typicalAccessusage.