You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2026/09/26 23:17:00 UTC

(datasketches-java) 04/04: CompactTupleSketch: write a zero seed hash for an empty image

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch fix-test-failures
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git

commit 1481c3fc76bf78bf79a0d4a3edffba877911694b
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sat Sep 26 16:16:47 2026 -0700

    CompactTupleSketch: write a zero seed hash for an empty image
    
    Follow the theta rule: a serialized empty compact sketch (8 bytes,
    preLongs = 1) carries a zero seed hash. C++ compact_tuple_sketch already
    does this, and no Java or C++ tuple reader checks the seed hash of an
    empty image, so this only brings the Java bytes in line with C++.
    
    Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
---
 src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java b/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
index 030eae7e5..4c2ed8ef6 100644
--- a/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
+++ b/src/main/java/org/apache/datasketches/tuple/CompactTupleSketch.java
@@ -221,7 +221,7 @@ public final class CompactTupleSketch<S extends Summary> extends TupleSketch<S>
       | (1 << Flags.IS_READ_ONLY.ordinal())
       | (isEmpty() ? 1 << Flags.IS_EMPTY.ordinal() : 0)
     );
-    ByteArrayUtil.putShortLE(bytes, offset, defaultSeedHash);
+    ByteArrayUtil.putShortLE(bytes, offset, isEmpty() ? 0 : defaultSeedHash); // empty image carries zero, as in theta
     offset += Short.BYTES;
     if (!isEmpty()) {
       if (!isSingleItem) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org