Skip to content
Permalink
Browse files
Deprecate all occurrences of serializing or deserializing UpdateSketch
or its derivatives.
  • Loading branch information
leerho committed Oct 23, 2021
1 parent 8ad0494 commit 7926128138f9521982653e69ba8b1f577f15dac1
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 8 deletions.
@@ -61,7 +61,11 @@ public FdtSketch(final int lgK) {
/**
* Used by deserialization.
* @param mem the image of a FdtSketch
* @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
FdtSketch(final Memory mem) {
super(mem);
}
@@ -140,6 +140,9 @@ private enum Flags { IS_BIG_ENDIAN, IS_IN_SAMPLING_MODE, IS_EMPTY, HAS_ENTRIES,
* @param mem Memory object with serialized QukckSelectSketch
* @param deserializer the SummaryDeserializer
* @param summaryFactory the SummaryFactory
* @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
QuickSelectSketch(
@@ -314,6 +317,13 @@ public CompactSketch<S> compact() {
// Adr:
// || 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// 0 || RF | lgArr | lgNom | Flags | SkType | FamID | SerVer | Preamble_Longs |
/**
* This serializes an UpdatableSketch (QuickSelectSketch).
* @return serialized representation of an UpdatableSketch (QuickSelectSketch).
* @deprecated As of 3.0.0, serializing an UpdatableSketch is deprecated.
* This capability will be removed in a future release.
* Serializing a CompactSketch is not deprecated.
*/
@Deprecated
@SuppressWarnings("null")
@Override
@@ -161,7 +161,11 @@ public double getTheta() {
}

/**
* This is to serialize an instance to a byte array.
* This is to serialize a sketch instance to a byte array.
*
* <p>As of 3.0.0, serializing an UpdatableSketch is deprecated.
* This capability will be removed in a future release.
* Serializing a CompactSketch is not deprecated.</p>
* @return serialized representation of the sketch
*/
public abstract byte[] toByteArray();
@@ -35,12 +35,17 @@ public static <S extends Summary> Sketch<S> createEmptySketch() {
}

/**
* Instantiate Sketch from a given Memory
* 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) {
final SerializerDeserializer.SketchType sketchType = SerializerDeserializer.getSketchType(mem);
@@ -58,10 +63,13 @@ public static <S extends Summary> Sketch<S> heapifySketch(final Memory mem,
* @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.
*/
public static <U, S extends
UpdatableSummary<U>> UpdatableSketch<U, S> heapifyUpdatableSketch(final Memory mem,
final SummaryDeserializer<S> deserializer, final SummaryFactory<S> summaryFactory) {
@Deprecated
public static <U, S extends UpdatableSummary<U>> UpdatableSketch<U, S> heapifyUpdatableSketch(
final Memory mem, final SummaryDeserializer<S> deserializer, final SummaryFactory<S> summaryFactory) {
return new UpdatableSketch<U, S>(mem, deserializer, summaryFactory);
}

@@ -65,7 +65,11 @@ public UpdatableSketch(final int nomEntries, final int lgResizeFactor,
* @param srcMem Memory object with data of a serialized UpdatableSketch
* @param deserializer instance of SummaryDeserializer
* @param summaryFactory instance of SummaryFactory
* @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 UpdatableSketch(final Memory srcMem, final SummaryDeserializer<S> deserializer,
final SummaryFactory<S> summaryFactory) {
super(srcMem, deserializer, summaryFactory);
@@ -62,7 +62,11 @@ public DoubleSketch(final int lgK, final int lgResizeFactor, final float samplin
* usually with data.
* @param mem the given Memory
* @param mode The DoubleSummary mode to be used
* @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 DoubleSketch(final Memory mem, final DoubleSummary.Mode mode) {
super(mem, new DoubleSummaryDeserializer(), new DoubleSummaryFactory(mode));
}
@@ -62,7 +62,11 @@ public IntegerSketch(final int lgK, final int lgResizeFactor, final float sampli
* usually with data.
* @param mem the given Memory
* @param mode The IntegerSummary mode to be used
* @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 IntegerSketch(final Memory mem, final IntegerSummary.Mode mode) {
super(mem, new IntegerSummaryDeserializer(), new IntegerSummaryFactory(mode));
}
@@ -64,7 +64,11 @@ public ArrayOfStringsSketch(final int lgK, final ResizeFactor rf, final float p)
* Constructs this sketch from a Memory image, which must be from an ArrayOfStringsSketch, and
* usually with data.
* @param mem the given Memory
* @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 ArrayOfStringsSketch(final Memory mem) {
super(mem, new ArrayOfStringsSummaryDeserializer(), new ArrayOfStringsSummaryFactory());
}
@@ -25,12 +25,11 @@

import java.util.List;

import org.testng.annotations.Test;

import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.tuple.SketchIterator;
import org.apache.datasketches.tuple.strings.ArrayOfStringsSummary;
import org.testng.annotations.Test;

/**
* @author Lee Rhodes
@@ -40,6 +39,7 @@ public class FdtSketchTest {
private static final String LS = System.getProperty("line.separator");
private static final char sep = '|'; //string separator

@SuppressWarnings("deprecation")
@Test
public void checkFdtSketch() {
final int lgK = 14;
@@ -175,6 +175,7 @@ public void serializeDeserializeEstimation() throws Exception {
Assert.assertEquals(count, 4096);
}

@SuppressWarnings("deprecation")
@Test(expectedExceptions = SketchesArgumentException.class)
public void deserializeWrongType() {
UpdatableSketch<Double, DoubleSummary> us =
@@ -63,6 +63,7 @@ public void checkLowK() {
assertEquals(sk.getLgK(), 4);
}

@SuppressWarnings("deprecation")
@Test
public void serDeTest() {
final int lgK = 12;
@@ -319,6 +320,7 @@ public void doubleSummaryMaxMode() {
}
}

@SuppressWarnings("deprecation")
@Test
public void serializeDeserializeExact() throws Exception {
final UpdatableSketch<Double, DoubleSummary> sketch1 =
@@ -343,6 +345,7 @@ public void serializeDeserializeExact() throws Exception {
Assert.assertEquals(sketch2.getEstimate(), 2.0);
}

@SuppressWarnings("deprecation")
@Test
public void serializeDeserializeEstimationNoResizing() throws Exception {
final UpdatableSketch<Double, DoubleSummary> sketch1 =
@@ -373,6 +376,7 @@ public void serializeDeserializeEstimationNoResizing() throws Exception {
Assert.assertEquals(count, 4096);
}

@SuppressWarnings("deprecation")
@Test
public void serializeDeserializeSampling() throws Exception {
final int sketchSize = 16384;
@@ -33,6 +33,7 @@
@SuppressWarnings("javadoc")
public class IntegerSketchTest {

@SuppressWarnings("deprecation")
@Test
public void serDeTest() {
final int lgK = 12;
@@ -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();

0 comments on commit 7926128

Please sign in to comment.