davecromberge opened a new issue, #807:
URL: https://github.com/apache/datasketches-java/issues/807

   **Use case**
   
   We build audience statistics by unrolling event data: each row's ID is added 
to many sketches at once, one per tag the end user belongs to (often hundreds 
per row), and to both a theta and a CPC sketch. Every update(id) computes the 
same seeded MurmurHash3 x64-128 again, so a row hashes one ID hundreds of times.
   
   **What I measured**
   
   Hashing each ID once per row and passing that hash to every sketch gives 
byte-identical sketches. It cut 16–26% of total compute in our production 
workloads, which are dominated by sketch updates. To get there we had to call 
the package-private methods by name through MethodHandles, which is fragile 
across releases.
   
   **Current state**
   
   The hash entry points already exist, but aren't public:
   - UpdatableThetaSketch.hashUpdate(long hash) (package-private, abstract), 
fed hash(datum, seed)[0] >>> 1;
   - CpcSketch.hashUpdate(long hash0, long hash1) (package-private).
   
   **Proposal**
   
   Make these public, or add public equivalents, with the contract that the 
caller computed MurmurHash3 x64-128 using the sketch's seed. Pairing them with 
a public helper that computes that hash for a given seed would make the 
contract hard to get wrong. For example:
   
   long[] h = UpdatableThetaSketch.hashOf(id, seed);   // or a shared hashing 
utility
   thetaSketch.hashUpdate(h[0] >>> 1);                          // or take the 
raw pair and shift internally
   cpcSketch.hashUpdate(h[0], h[1]);
   
   Sketches built this way stay compatible with ones built from items, as long 
as the seed matches.
   
   **Questions**
   - Is exposing this acceptable, given that responsibility for the seed moves 
to the caller?
   - Should the theta method take the raw 128-bit pair and apply >>> 1 itself, 
so theta and CPC share one input?
   - Should the same API go to datasketches-cpp and datasketches-rust, so the 
languages stay consistent? We also need it in Rust.
   
   If this is acceptable, I'm able to contribute PRs with tests showing parity 
between update(item) and hashUpdate(hash).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to