Removed some deprecated classes
diff --git a/src/main/java/org/apache/datasketches/theta/PairwiseSetOperations.java b/src/main/java/org/apache/datasketches/theta/PairwiseSetOperations.java
deleted file mode 100644
index 1b801f9..0000000
--- a/src/main/java/org/apache/datasketches/theta/PairwiseSetOperations.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.datasketches.theta;
-
-import org.apache.datasketches.thetacommon.ThetaUtil;
-
-/**
- * Set Operations where the arguments are presented in pairs as in <i>C = Op(A,B)</i>. These are
- * stateless operations and the result is returned immediately.
- *
- * <p>These operations are designed for convenience and accept Sketches that may be either
- * Heap-based or Direct.
- *
- * @author Lee Rhodes
- * @deprecated v2.0.0. This class has been deprecated as equivalent functionality has been added to the
- * SetOperation classes: {@link Union}, {@link Intersection} and {@link AnotB}.
- */
-@Deprecated
-public class PairwiseSetOperations {
-
- /**
- * This implements a stateless, pair-wise <i>Intersect</i> operation on sketches
- * that are either Heap-based or Direct.
- * If either inputs are null or empty an EmptyCompactSketch is returned.
- *
- * @param skA The first Sketch argument.
- * @param skB The second Sketch argument.
- * @return the result as an ordered CompactSketch on the heap.
- * @deprecated v2.0.0. Use {@link Intersection#intersect(Sketch, Sketch)} instead, which has more
- * complete seed handling.
- */
- @Deprecated
- public static CompactSketch intersect(final Sketch skA, final Sketch skB) {
- final Intersection inter = new SetOperationBuilder().buildIntersection();
- return inter.intersect(skA, skB);
- }
-
- /**
- * This implements a stateless, pair-wise <i>A AND NOT B</i> operation on Sketches
- * that are either Heap-based or Direct.
- * If both inputs are null an EmptyCompactSketch is returned.
- *
- * @param skA The first Sketch argument.
- * @param skB The second Sketch argument.
- * @return the result as an ordered CompactSketch on the heap.
- * @deprecated v2.0.0. Use {@link AnotB#aNotB(Sketch, Sketch)} instead, which has more
- * complete seed handling.
- */
- @Deprecated
- public static CompactSketch aNotB(final Sketch skA, final Sketch skB) {
- final AnotB anotb = new SetOperationBuilder().buildANotB();
- return anotb.aNotB(skA, skB);
- }
-
- /**
- * This implements a stateless, pair-wise union operation on ordered,
- * CompactSketches that are either Heap-based or Direct.
- * Having the input sketches be compact and ordered enables extremely fast union operation.
- * If both inputs are null an EmptyCompactSketch is returned.
- * If one is null the other is returned, which can be either Heap-based or Direct.
- * This is equivalent to union(skA, skB, k) where k is the default of 4096.
- *
- * @param skA The first ordered, CompactSketch argument.
- * @param skB The second ordered, CompactSketch argument
- * @return the result as an ordered CompactSketch.
- * @deprecated v2.0.0. Please use {@link Union#union(Sketch, Sketch)} instead, which has more
- * complete seed handling.
- */
- @Deprecated
- public static CompactSketch union(final CompactSketch skA, final CompactSketch skB) {
- return union(skA, skB, ThetaUtil.DEFAULT_NOMINAL_ENTRIES);
- }
-
- /**
- * This implements a stateless, pair-wise union operation on ordered,
- * CompactSketches that are either Heap-based or Direct. The returned sketch will be cutback to
- * k if required, similar to the regular Union operation. If a cutback is required, the returned
- * sketch will always be on the heap.
- * If both inputs are null a null is returned. If either sketch is empty its Theta is ignored.
- * If one is null the other is returned, which may be either Direct or heap-based if a cutback
- * is required.
- *
- * @param skA The first ordered, CompactSketch argument.
- * @param skB The second ordered, CompactSketch argument
- * @param k The upper bound of the number of entries to be retained by the sketch
- * @return the result as an ordered CompactSketch.
- * @deprecated v2.0.0. Please use {@link Union#union(Sketch, Sketch)} instead, which has more
- * complete seed handling.
- */
- @Deprecated
- public static CompactSketch union(final CompactSketch skA, final CompactSketch skB, final int k) {
- final Union un = new SetOperationBuilder().setNominalEntries(k).buildUnion();
- return un.union(skA, skB);
- }
-
-}
diff --git a/src/main/java/org/apache/datasketches/tuple/Sketches.java b/src/main/java/org/apache/datasketches/tuple/Sketches.java
index ab9cfb3..b4c1eed 100644
--- a/src/main/java/org/apache/datasketches/tuple/Sketches.java
+++ b/src/main/java/org/apache/datasketches/tuple/Sketches.java
@@ -24,6 +24,7 @@
/**
* Convenient static methods to instantiate generic tuple sketches.
*/
+@SuppressWarnings("deprecation")
public final class Sketches {
/**
@@ -36,16 +37,11 @@
/**
* Instantiate a Sketch from a given Memory.
- *
- * <p>As of 3.0.0, heapifying an UpdatableSketch is deprecated.
- * This capability will be removed in a future release.
- * Heapifying a CompactSketch is not deprecated.</p>
* @param <S> Type of Summary
* @param mem Memory object representing a Sketch
* @param deserializer instance of SummaryDeserializer
* @return Sketch created from its Memory representation
*/
- @SuppressWarnings("deprecation")
public static <S extends Summary> Sketch<S> heapifySketch(
final Memory mem,
final SummaryDeserializer<S> deserializer) {
@@ -64,11 +60,7 @@
* @param deserializer instance of SummaryDeserializer
* @param summaryFactory instance of SummaryFactory
* @return Sketch created from its Memory representation
- * @deprecated As of 3.0.0, heapifying an UpdatableSketch is deprecated.
- * This capability will be removed in a future release.
- * Heapifying a CompactSketch is not deprecated.
*/
- @Deprecated
public static <U, S extends UpdatableSummary<U>> UpdatableSketch<U, S> heapifyUpdatableSketch(
final Memory mem,
final SummaryDeserializer<S> deserializer,
diff --git a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
index 51e1a81..203f491 100644
--- a/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
+++ b/src/test/java/org/apache/datasketches/theta/PairwiseSetOperationsTest.java
@@ -25,7 +25,6 @@
import org.apache.datasketches.common.SketchesArgumentException;
import org.testng.annotations.Test;
-@SuppressWarnings("deprecation")
public class PairwiseSetOperationsTest {
// Intersection
@@ -45,8 +44,8 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
-
- Sketch rsk = PairwiseSetOperations.intersect(csk1, csk2);
+ Intersection inter = Sketches.setOperationBuilder().buildIntersection();
+ Sketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0);
}
@@ -57,6 +56,7 @@
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ Intersection inter = Sketches.setOperationBuilder().buildIntersection();
for (int i=0; i<k; i++) { //<k so est is exact
usk1.update(i);
@@ -66,7 +66,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = PairwiseSetOperations.intersect(csk1, csk2);
+ Sketch rsk = inter.intersect(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -91,8 +91,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
-
- Sketch rsk = PairwiseSetOperations.intersect(csk1, csk2);
+ Sketch rsk = inter.intersect(csk1, csk2);
double result1 = rsk.getEstimate();
inter.intersect(csk1);
@@ -117,6 +116,7 @@
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ AnotB anotb = Sketches.setOperationBuilder().buildANotB();
for (int i=0; i<k; i++) {
usk1.update(i);
@@ -126,7 +126,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = PairwiseSetOperations.aNotB(csk1, csk2);
+ Sketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -137,6 +137,7 @@
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ AnotB anotb = Sketches.setOperationBuilder().buildANotB();
for (int i=0; i<k; i++) {
usk1.update(i);
@@ -146,7 +147,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = PairwiseSetOperations.aNotB(csk1, csk2);
+ Sketch rsk = anotb.aNotB(csk1, csk2);
assertEquals(rsk.getEstimate(), 0.0, 0.0);
}
@@ -172,7 +173,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = PairwiseSetOperations.aNotB(csk1, csk2);
+ Sketch rsk = aNotB.aNotB(csk1, csk2);
double result1 = rsk.getEstimate();
CompactSketch csk3 = aNotB.aNotB(csk1, csk2);
@@ -208,9 +209,9 @@
union.union(csk2);
Sketch stdSk = union.getResult(true, null);
- Sketch pwSk = PairwiseSetOperations.union(csk1, csk2, k);
+ Sketch rsk = union.union(csk1, csk2);
- assertEquals(pwSk.getEstimate(), stdSk.getEstimate(), 0.0);
+ assertEquals(rsk.getEstimate(), stdSk.getEstimate(), 0.0);
}
@Test
@@ -220,6 +221,7 @@
UpdateSketch usk1 = UpdateSketch.builder().setNominalEntries(k).build();
UpdateSketch usk2 = UpdateSketch.builder().setNominalEntries(k).build();
+ Union union = Sketches.setOperationBuilder().setNominalEntries(k).buildUnion();
for (int i=0; i<k; i++) {
usk1.update(i);
@@ -229,7 +231,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch rsk = PairwiseSetOperations.union(csk1, csk2, k);
+ Sketch rsk = union.union(csk1, csk2);
assertEquals(rsk.getEstimate(), k, 0.0);
}
@@ -255,7 +257,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = PairwiseSetOperations.union(csk1, csk2, 2 * k);
+ Sketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
@@ -289,7 +291,7 @@
CompactSketch csk1 = usk1.compact(true, null);
CompactSketch csk2 = usk2.compact(true, null);
- Sketch pwSk = PairwiseSetOperations.union(csk1, csk2, k);
+ Sketch pwSk = union.union(csk1, csk2);
double pwEst = pwSk.getEstimate();
union.union(csk1);
@@ -357,23 +359,23 @@
AnotB aNotB = SetOperation.builder().buildANotB();
Intersection inter = SetOperation.builder().buildIntersection();
- checkSetOps(union, inter, aNotB, k, cskAempty, cskBempty); //Empty, Empty
- checkSetOps(union, inter, aNotB, k, cskA1, cskBempty); //NotEmpty, Empty
- checkSetOps(union, inter, aNotB, k, cskAempty, cskA1); //Empty, NotEmpty
+ checkSetOps(union, inter, aNotB, cskAempty, cskBempty); //Empty, Empty
+ checkSetOps(union, inter, aNotB, cskA1, cskBempty); //NotEmpty, Empty
+ checkSetOps(union, inter, aNotB, cskAempty, cskA1); //Empty, NotEmpty
}
- private static void checkSetOps(Union union, Intersection inter, AnotB aNotB, int k,
+ private static void checkSetOps(Union union, Intersection inter, AnotB aNotB,
CompactSketch cskA, CompactSketch cskB) {
- checkUnion(union, cskA, cskB, k);
+ checkUnion(union, cskA, cskB);
checkIntersection(inter, cskA, cskB);
checkAnotB(aNotB, cskA, cskB);
}
- private static void checkUnion(Union union, CompactSketch cskA, CompactSketch cskB, int k) {
+ private static void checkUnion(Union union, CompactSketch cskA, CompactSketch cskB) {
union.union(cskA);
union.union(cskB);
CompactSketch cskU = union.getResult();
- CompactSketch cskP = PairwiseSetOperations.union(cskA, cskB, k);
+ CompactSketch cskP = union.union(cskA, cskB);
assertEquals(cskU.isEmpty(), cskP.isEmpty());
union.reset();
}
@@ -382,14 +384,14 @@
inter.intersect(cskA);
inter.intersect(cskB);
CompactSketch cskI = inter.getResult();
- CompactSketch cskP = PairwiseSetOperations.intersect(cskA, cskB);
+ CompactSketch cskP = inter.intersect(cskA, cskB);
assertEquals(cskI.isEmpty(), cskP.isEmpty());
inter.reset();
}
private static void checkAnotB(AnotB aNotB, CompactSketch cskA, CompactSketch cskB) {
CompactSketch cskD = aNotB.aNotB(cskA, cskB);
- CompactSketch cskP = PairwiseSetOperations.aNotB(cskA, cskB);
+ CompactSketch cskP = aNotB.aNotB(cskA, cskB);
assertEquals(cskD.isEmpty(), cskP.isEmpty());
}
diff --git a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
index 05b91f8..9696b20 100644
--- a/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SetOpsCornerCasesTest.java
@@ -33,7 +33,6 @@
import org.testng.Assert;
import org.testng.annotations.Test;
-@SuppressWarnings("deprecation")
public class SetOpsCornerCasesTest {
/*******************************************/
@@ -207,15 +206,18 @@
else { tcskA = (tskA instanceof CompactSketch) ? (CompactSketch) tskA : tskA.compact(); }
if (tskB == null) { tcskB = null; }
else { tcskB = (tskB instanceof CompactSketch) ? (CompactSketch) tskB : tskB.compact(); }
- return PairwiseSetOperations.union(tcskA, tcskB, k);
+ Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ return union.union(tcskA, tcskB);
}
private static CompactSketch doPwIntersection(Sketch tskA, Sketch tskB) {
- return PairwiseSetOperations.intersect(tskA, tskB);
+ Intersection inter = SetOperation.builder().buildIntersection();
+ return inter.intersect(tskA, tskB);
}
private static CompactSketch doPwAnotB(Sketch tskA, Sketch tskB) {
- return PairwiseSetOperations.aNotB(tskA, tskB);
+ AnotB aNotB = SetOperation.builder().buildANotB();
+ return aNotB.aNotB(tskA, tskB);
}
@@ -244,13 +246,13 @@
CompactSketch skEmpty = generate(EMPTY, k);
CompactSketch skHeap = generate(EST_HEAP, k);
CompactSketch skHeapUO = generate(EST_MEMORY_UNORDERED, k);
-
- PairwiseSetOperations.union(skNull, skHeapUO, k);
- PairwiseSetOperations.union(skEmpty, skHeapUO, k);
- PairwiseSetOperations.union(skHeapUO, skNull, k);
- PairwiseSetOperations.union(skHeapUO, skEmpty, k);
- PairwiseSetOperations.union(skHeapUO, skHeap, k);
- PairwiseSetOperations.union(skHeap, skHeapUO, k);
+ Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+ union.union(skNull, skHeapUO);
+ union.union(skEmpty, skHeapUO);
+ union.union(skHeapUO, skNull);
+ union.union(skHeapUO, skEmpty);
+ union.union(skHeapUO, skHeap);
+ union.union(skHeap, skHeapUO);
}
@Test
@@ -268,55 +270,60 @@
CompactSketch skExact = generate(EXACT, k);
CompactSketch skHeap = generate(EST_HEAP, 2 * k);
+
+ Intersection inter = SetOperation.builder().buildIntersection();
+ AnotB aNotB = SetOperation.builder().buildANotB();
+ Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
+
//Intersect
try {
- PairwiseSetOperations.intersect(skExact, skSmallSeed2A);
+ inter.intersect(skExact, skSmallSeed2A);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.intersect(skExact, skSmallSeed2B);
+ inter.intersect(skExact, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.intersect(skSmallSeed2B, skExact);
+ inter.intersect(skSmallSeed2B, skExact);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.intersect(skHeap, skSmallSeed2B);
+ inter.intersect(skHeap, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
//A NOT B
try {
- PairwiseSetOperations.aNotB(skExact, skSmallSeed2A);
+ aNotB.aNotB(skExact, skSmallSeed2A);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.aNotB(skExact, skSmallSeed2B);
+ aNotB.aNotB(skExact, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.aNotB(skSmallSeed2B, skExact);
+ aNotB.aNotB(skSmallSeed2B, skExact);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.aNotB(skHeap, skSmallSeed2B);
+ aNotB.aNotB(skHeap, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
//Union
try {
- PairwiseSetOperations.union(skExact, skSmallSeed2A);
+ union.union(skExact, skSmallSeed2A);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.union(skExact, skSmallSeed2B);
+ union.union(skExact, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.union(skSmallSeed2B, skExact);
+ union.union(skSmallSeed2B, skExact);
Assert.fail();
} catch (Exception e) { } //pass
try {
- PairwiseSetOperations.union(skHeap, skSmallSeed2B);
+ union.union(skHeap, skSmallSeed2B);
Assert.fail();
} catch (Exception e) { } //pass
}
@@ -328,16 +335,17 @@
CompactSketch skEmpty = generate(EMPTY, k);
CompactSketch skHeap1 = generate(EST_HEAP, k);
CompactSketch skHeap2 = generate(EST_HEAP, k);
+ Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
CompactSketch csk;
- csk = PairwiseSetOperations.union(skNull, skHeap1, k);
+ csk = union.union(skNull, skHeap1);
Assert.assertEquals(csk.getRetainedEntries(true), k);
- csk = PairwiseSetOperations.union(skEmpty, skHeap1, k);
+ csk = union.union(skEmpty, skHeap1);
Assert.assertEquals(csk.getRetainedEntries(true), k);
- csk = PairwiseSetOperations.union(skHeap1, skNull, k);
+ csk = union.union(skHeap1, skNull);
Assert.assertEquals(csk.getRetainedEntries(true), k);
- csk = PairwiseSetOperations.union(skHeap1, skEmpty, k);
+ csk = union.union(skHeap1, skEmpty);
Assert.assertEquals(csk.getRetainedEntries(true), k);
- csk = PairwiseSetOperations.union(skHeap1, skHeap2, k);
+ csk = union.union(skHeap1, skHeap2);
Assert.assertEquals(csk.getRetainedEntries(true), k);
}
diff --git a/src/test/java/org/apache/datasketches/tuple/CompactSketchWithDoubleSummaryTest.java b/src/test/java/org/apache/datasketches/tuple/CompactSketchWithDoubleSummaryTest.java
index dde6c47..045777c 100644
--- a/src/test/java/org/apache/datasketches/tuple/CompactSketchWithDoubleSummaryTest.java
+++ b/src/test/java/org/apache/datasketches/tuple/CompactSketchWithDoubleSummaryTest.java
@@ -172,7 +172,6 @@
Assert.assertEquals(count, 4096);
}
- @SuppressWarnings("deprecation")
@Test(expectedExceptions = SketchesArgumentException.class)
public void deserializeWrongType() {
UpdatableSketch<Double, DoubleSummary> us =