From c3a1b86b6670e010e56304fe643aaafec6e11c9a Mon Sep 17 00:00:00 2001 From: David Cromberge Date: Tue, 28 Sep 2021 12:24:47 +0100 Subject: [PATCH 1/2] Remove deprecated Tuple union update method --- .../java/org/apache/datasketches/tuple/Union.java | 13 ------------- .../tuple/strings/ArrayOfStringsSketchTest.java | 5 ++--- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/datasketches/tuple/Union.java b/src/main/java/org/apache/datasketches/tuple/Union.java index 467507f8f..aab5da788 100644 --- a/src/main/java/org/apache/datasketches/tuple/Union.java +++ b/src/main/java/org/apache/datasketches/tuple/Union.java @@ -102,19 +102,6 @@ public CompactSketch union(final Sketch tupleSketch, return csk; } - /** - * Performs a stateful union of the internal set with the given tupleSketch. - * @param tupleSketch input tuple sketch to add to the internal set. - * - *

Nulls and empty sketches are ignored.

- * - * @deprecated 2.0.0. Please use {@link #union(org.apache.datasketches.tuple.Sketch)}. - */ - @Deprecated - public void update(final Sketch tupleSketch) { - union(tupleSketch); - } - /** * Performs a stateful union of the internal set with the given tupleSketch. * @param tupleSketch input tuple sketch to merge with the internal set. diff --git a/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java b/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java index 00e2bd457..73b207af9 100644 --- a/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java +++ b/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java @@ -37,7 +37,6 @@ public class ArrayOfStringsSketchTest { private static final String LS = System.getProperty("line.separator"); - @SuppressWarnings("deprecation") @Test public void checkSketch() { ArrayOfStringsSketch sketch1 = new ArrayOfStringsSketch(); @@ -58,8 +57,8 @@ public void checkSketch() { sketch2.update(strArr3, strArr3); Union union = new Union<>(new ArrayOfStringsSummarySetOperations()); - union.update(sketch1); - union.update(sketch2); + union.union(sketch1); + union.union(sketch2); CompactSketch csk = union.getResult(); //printSummaries(csk.iterator()); assertEquals(csk.getRetainedEntries(), 4); From d61a6a4214e5ab3a2879bff190dae0f78161aaa0 Mon Sep 17 00:00:00 2001 From: David Cromberge Date: Tue, 28 Sep 2021 12:41:31 +0100 Subject: [PATCH 2/2] Remove deprecated methods on Tuple AnotB --- .../org/apache/datasketches/tuple/AnotB.java | 36 ------------------- .../tuple/adouble/AdoubleAnotBTest.java | 18 ++++++---- .../tuple/aninteger/IntegerSketchTest.java | 5 +-- .../strings/ArrayOfStringsSketchTest.java | 6 ++-- 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/apache/datasketches/tuple/AnotB.java b/src/main/java/org/apache/datasketches/tuple/AnotB.java index a7fe7528b..1a355e20c 100644 --- a/src/main/java/org/apache/datasketches/tuple/AnotB.java +++ b/src/main/java/org/apache/datasketches/tuple/AnotB.java @@ -384,7 +384,6 @@ private static DataArrays getResultArraysTuple( return daB; } - @SuppressWarnings("unchecked") private static DataArrays getResultArraysTheta( final long minThetaLong, @@ -432,7 +431,6 @@ private static DataArrays getResultArraysTheta( return daB; } - /** * Resets this sketch back to the empty state. */ @@ -444,38 +442,4 @@ private void reset() { curCount_ = 0; } - //Deprecated methods - - /** - * Perform A-and-not-B set operation on the two given sketches. - * A null sketch is interpreted as an empty sketch. - * This is not an accumulating update. Calling this update() more than once - * without calling getResult() will discard the result of previous update() by this method. - * The result is obtained by calling getResult(); - * - * @param skA The incoming sketch for the first argument - * @param skB The incoming sketch for the second argument - * @deprecated v2.0.0. Instead please use {@link #aNotB(Sketch, Sketch)}. - */ - @Deprecated - public void update(final Sketch skA, final Sketch skB) { - //duplicate old behavior - reset(); - if (skA == null) { return; } - else { setA(skA); } - if (skB == null) { return; } - else { notB(skB); } - } - - /** - * Gets the result of this operation. This clears the state of this operator after the result is - * returned. - * @return the result of this operation as an unordered {@link CompactSketch} - * @deprecated v2.0.0. Instead use {@link #getResult(boolean)}. - */ - @Deprecated - public CompactSketch getResult() { - return getResult(true); - } - } diff --git a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java index a2eae9d3a..8f8115fa1 100644 --- a/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java +++ b/src/test/java/org/apache/datasketches/tuple/adouble/AdoubleAnotBTest.java @@ -44,7 +44,6 @@ public class AdoubleAnotBTest { private static final DoubleSummary.Mode mode = Mode.Sum; private final Results results = new Results(); - @SuppressWarnings("deprecation") private static void threeMethodsWithTheta( final AnotB aNotB, final Sketch skA, @@ -54,11 +53,16 @@ private static void threeMethodsWithTheta( { CompactSketch result; - //Deprecated v2.0.0., Stateless, A = Tuple, B = Tuple - //Old behavior is tolerant of nulls - aNotB.update(skA, skB); - result = aNotB.getResult(); - results.check(result); + //Stateful, A = Tuple, B = Tuple + if (skA != null) { + try { + aNotB.setA(skA); + aNotB.notB(skB); + result = aNotB.getResult(true); + results.check(result); + } + catch (final SketchesArgumentException e) { } + } //Stateless A = Tuple, B = Tuple if (skA == null || skB == null) { @@ -160,7 +164,7 @@ private static UpdateSketch buildUpdateTheta() { public void aNotBNullEmptyCombinations() { final AnotB aNotB = new AnotB<>(); // calling getResult() before calling update() should yield an empty set - final CompactSketch result = aNotB.getResult(); + final CompactSketch result = aNotB.getResult(true); results.set(0, true, 0.0, 0.0, 0.0).check(result); final UpdatableSketch sketch = buildUpdatableTuple(); diff --git a/src/test/java/org/apache/datasketches/tuple/aninteger/IntegerSketchTest.java b/src/test/java/org/apache/datasketches/tuple/aninteger/IntegerSketchTest.java index d12339c98..4a877f787 100644 --- a/src/test/java/org/apache/datasketches/tuple/aninteger/IntegerSketchTest.java +++ b/src/test/java/org/apache/datasketches/tuple/aninteger/IntegerSketchTest.java @@ -82,8 +82,9 @@ public void aNotBTest() { for (int i = 0; i < u; i++) { a1Sk1.update(i, 1); } - anotb.update(a1Sk1, a1Sk2); - final CompactSketch cSk = anotb.getResult(); + anotb.setA(a1Sk1); + anotb.notB(a1Sk2); + final CompactSketch cSk = anotb.getResult(true); assertEquals((int)cSk.getEstimate(), u); } diff --git a/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java b/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java index 73b207af9..f5e388184 100644 --- a/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java +++ b/src/test/java/org/apache/datasketches/tuple/strings/ArrayOfStringsSketchTest.java @@ -37,6 +37,7 @@ public class ArrayOfStringsSketchTest { private static final String LS = System.getProperty("line.separator"); + @SuppressWarnings("deprecation") @Test public void checkSketch() { ArrayOfStringsSketch sketch1 = new ArrayOfStringsSketch(); @@ -71,8 +72,9 @@ public void checkSketch() { assertEquals(csk.getRetainedEntries(), 3); AnotB aNotB = new AnotB<>(); - aNotB.update(sketch2, sketch1); - csk = aNotB.getResult(); + aNotB.setA(sketch2); + aNotB.notB(sketch1); + csk = aNotB.getResult(true); assertEquals(csk.getRetainedEntries(), 1); }