From 737a7cc79174ad5c4b2288d0474d8a0fbbb0bd8e Mon Sep 17 00:00:00 2001 From: Pierre Lacave Date: Thu, 7 Dec 2023 00:41:31 +0100 Subject: [PATCH 1/2] break a test using a pure function --- src/test/java/org/apache/datasketches/hll/UnionTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/apache/datasketches/hll/UnionTest.java b/src/test/java/org/apache/datasketches/hll/UnionTest.java index 255834fa4..bbbee5622 100644 --- a/src/test/java/org/apache/datasketches/hll/UnionTest.java +++ b/src/test/java/org/apache/datasketches/hll/UnionTest.java @@ -449,6 +449,7 @@ public void checkUnionHeapifyRebuildAfterMerge() { Union union1 = new Union(lgK, wmem); //Create original union off-heap union1.update(sk1); union1.update(sk2); //oooFlag = Rebuild_KxQ = TRUE + assertTrue(!union1.toString().isEmpty()); boolean rebuild = PreambleUtil.extractRebuildCurMinNumKxQFlag(wmem); double hipAccum = PreambleUtil.extractHipAccum(wmem); assertTrue(rebuild); From b310591ed83739ce724a312c86a1690c465d5271 Mon Sep 17 00:00:00 2001 From: Pierre Lacave Date: Thu, 7 Dec 2023 00:44:39 +0100 Subject: [PATCH 2/2] keep Union HLL toString pure --- src/main/java/org/apache/datasketches/hll/Union.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/datasketches/hll/Union.java b/src/main/java/org/apache/datasketches/hll/Union.java index 3d33ba90d..986537941 100644 --- a/src/main/java/org/apache/datasketches/hll/Union.java +++ b/src/main/java/org/apache/datasketches/hll/Union.java @@ -306,8 +306,9 @@ public byte[] toUpdatableByteArray() { @Override public String toString(final boolean summary, final boolean hllDetail, final boolean auxDetail, final boolean all) { - checkRebuildCurMinNumKxQ(gadget); - return gadget.toString(summary, hllDetail, auxDetail, all); + HllSketch clone = gadget.copy(); + checkRebuildCurMinNumKxQ(clone); + return clone.toString(summary, hllDetail, auxDetail, all); } /**