XXH64 non-cryptographic hash in pure OCaml
0

Configure Feed

Select the types of activity you want to include in your feed.

tree: reformat for the upgraded ocamlformat

Comment reflow and header reindent produced by the new ocamlformat;
no code changes.

+12 -14
+2 -2
fuzz/fuzz_xxhash.ml
··· 2 2 3 3 open Alcobar 4 4 5 - (* Hashing must succeed for inputs of every length without reading out of 6 - bounds -- this exercises the gating around the 32-byte stripe loop and the 5 + (* Hashing must succeed for inputs of every length without reading out of bounds 6 + -- this exercises the gating around the 32-byte stripe loop and the 7 7 8/4/1-byte tail steps -- and must be deterministic. *) 8 8 let test_total_and_deterministic s = 9 9 let a = Xxhash.hash64_string s in
+6 -7
lib/xxhash.ml
··· 1 1 (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> 3 - Copyright (c) 2026 Thomas Gazagnaire 4 - SPDX-License-Identifier: ISC 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> Copyright (c) 2026 3 + Thomas Gazagnaire SPDX-License-Identifier: ISC 5 4 6 - Pure-OCaml XXH64, merged from anil.recoil.org/ocaml-mlxxhash (the richer 7 - implementation: zero-copy bytes/pos/len primitive, hash32, and a streaming 8 - state) with Thomas's ocaml-xxhash (validated against the Parquet split-block 9 - bloom-filter fixtures). All arithmetic is modulo 2^64, which Int64 provides. 5 + Pure-OCaml XXH64, merged from anil.recoil.org/ocaml-mlxxhash (the richer 6 + implementation: zero-copy bytes/pos/len primitive, hash32, and a streaming 7 + state) with Thomas's ocaml-xxhash (validated against the Parquet split-block 8 + bloom-filter fixtures). All arithmetic is modulo 2^64, which Int64 provides. 10 9 ---------------------------------------------------------------------------*) 11 10 12 11 let prime64_1 = 0x9E3779B185EBCA87L
+2 -3
lib/xxhash.mli
··· 1 1 (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> 3 - Copyright (c) 2026 Thomas Gazagnaire 4 - SPDX-License-Identifier: ISC 2 + Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org> Copyright (c) 2026 3 + Thomas Gazagnaire SPDX-License-Identifier: ISC 5 4 ---------------------------------------------------------------------------*) 6 5 7 6 (** The xxHash non-cryptographic hash (XXH64), pure OCaml.
+2 -2
test/test_xxhash.ml
··· 4 4 one-shot consistency, boundary conditions, and basic properties. *) 5 5 6 6 (* The official xxHash test suite hashes a deterministic pseudo-random buffer: 7 - byteGen starts at PRIME32, each byte is (byteGen >> 56) & 0xFF, then 8 - byteGen *= PRIME64. (Note this PRIME64 is the test generator's, not the 7 + byteGen starts at PRIME32, each byte is (byteGen >> 56) & 0xFF, then byteGen 8 + *= PRIME64. (Note this PRIME64 is the test generator's, not the 9 9 algorithm's.) *) 10 10 let prime32 = 2654435761L 11 11 let prime64_gen = 0x9e3779b185ebca8dL