Skip to content

Add ItemHash for updating sketches with a precomputed hash - #820

Open
davecromberge wants to merge 1 commit into
mainfrom
item-hash
Open

davecromberge wants to merge 1 commit into
mainfrom
item-hash

Conversation

@davecromberge

Copy link
Copy Markdown
Member

Adds ItemHash so an item can be hashed once and the result passed to several sketches, as discussed in #807.

ItemHash holds the canonicalized 128-bit MurmurHash3 of an item and the
seed it was computed with. Theta, Tuple, ArrayOfDoubles, CPC and HLL route
their update(item) methods through it and gain update(ItemHash), which
rejects hashes computed with a different seed. Serialized sketches are
unchanged.
@davecromberge
davecromberge requested a review from leerho November 27, 2026 11:23

@leerho leerho left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You stated that it produces identical hashes. And from studying the design, it follows what we talked about in Issue #807 and LGTM. Nonetheless, there are some changes I would like to see.

  1. See inline comment: I would prefer the name "UpdateHash".
  2. You commented that you saw no slowdown due to the extra object per update. A JMH result in the PR would settle it.
  3. ThetaUnion has no update(ItemHash), so coverage across the sketches is incomplete.

* several sketches that share the seed, producing the same result as updating each with the item.
* The factory methods return null for null or empty items, which sketches ignore.</p>
*/
public final class ItemHash {

@leerho leerho Dec 6, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better name for this factory would be "UpdateHash". It communicates what it produces and what it is used for. The problem I have with "ItemHash" is "Item" is already used in the library to refer to arbitrary objects that are not primitives. This factory hashes primitives and a few objects, String, ByteBuffer, MemorySegment, primitive arrays, but it is a limited list.

This branch has not been deployed

No deployments
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.

2 participants