Skip to content

[#68] Document Murmur3 64-bit seed semantics and C++ interoperability - #120

Open
peter-lawrey wants to merge 3 commits into
developfrom
docs/Zero-Allocation-Hashing-68-javadoc-note-c-parity-is-for-uint3
Open

[#68] Document Murmur3 64-bit seed semantics and C++ interoperability#120
peter-lawrey wants to merge 3 commits into
developfrom
docs/Zero-Allocation-Hashing-68-javadoc-note-c-parity-is-for-uint3

Conversation

@peter-lawrey

@peter-lawrey peter-lawrey commented Aug 20, 2026

Copy link
Copy Markdown
Member

What changed

  • Document that murmur_3(long) uses all 64 bits of its seed.
  • Define C++ interoperability in terms of the reference implementation's
    uint32_t seed and the same input byte sequence.
  • Explain how to zero-extend a signed Java int with
    Integer.toUnsignedLong.
  • Document the contract on both the 64-bit and 128-bit public APIs.
  • Add C++ reference vectors at the 0x80000000 and 0xffffffff boundaries,
    checking both output words and the 64-bit API's first-word result.

Why

The C++ MurmurHash3_x64_128 reference accepts a uint32_t seed, while this
library has historically accepted and used a full Java long. Masking the
existing parameter would change established hash values, including potentially
persisted values, so this PR clarifies the contract without changing behaviour.

An int overload is deliberately not added: existing source calls such as
murmur_3(-1) currently bind to the long overload. A new overload with
zero-extension semantics would silently change their result after recompilation
while existing binaries retained the old result.

Validation

  • Java 8: mvn -B clean verify
    • 14,904 tests, 0 failures, 0 errors, 12 skipped
    • Checkstyle, Javadocs and licence checks passed
  • Independently generated and verified the two boundary vectors with Austin
    Appleby's C++ MurmurHash3_x64_128 reference implementation
  • git diff --check

Fixes #68

The C++ reference accepts uint32_t while the established Java API uses all 64 bits of its long seed. Changing that behaviour would alter existing hash values.

Document both public facades and add independent boundary vectors without changing production behaviour.
@peter-lawrey
peter-lawrey force-pushed the docs/Zero-Allocation-Hashing-68-javadoc-note-c-parity-is-for-uint3 branch from aa8e611 to 9a4536e Compare August 21, 2026 14:11
@peter-lawrey peter-lawrey changed the title [#68] Murmur3 is incompatible with C++ reference implementation for negative seed values [#68] Document Murmur3 64-bit seed semantics and C++ interoperability Aug 21, 2026
@peter-lawrey peter-lawrey self-assigned this Aug 21, 2026
@peter-lawrey
peter-lawrey marked this pull request as ready for review August 21, 2026 14:16
@peter-lawrey
peter-lawrey changed the base branch from ea to develop August 21, 2026 14:17
@peter-lawrey
peter-lawrey requested a review from tgd August 21, 2026 14:17
The Build job failed during setup because both cache steps used the retired cache v1 service. The checkout and Java setup actions also used obsolete runtimes, and the SonarCloud scanner engine now requires Java 21.

Upgrade checkout, Java setup and both cache steps to v4, select Zulu JDK 21 explicitly and document the CI runtime. Preserve the Java 8 bytecode target and existing cache keys.

Validate with actionlint 1.7.12 and mvn -B clean verify -Psonar on JDK 11 and 21. Each build runs 14,904 tests twice, with zero failures or errors and 5/8 skips for the respective string configurations.
The repaired run passed setup and the Maven build, but GitHub reported that the v4 actions use deprecated Node 20 runtimes and setup-java v4 no longer receives updates.

Use checkout v7, setup-java v6 and cache v6, whose documented inputs preserve this workflow configuration. Actionlint 1.7.12 and git diff --check pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Murmur3 is incompatible with C++ reference implementation for negative seed values

2 participants