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 2020/07/07 23:37:08 UTC
[incubator-datasketches-java] 05/10: Deprecated
getCurrentBytes(boolean). Replaced by getCompactBytes() and
getCurrentBytes().
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch Refactor_Theta_Tuple
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-java.git
commit 50f49bfc6f3442e3d92b93436242fb01e1b3bbe3
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Mon Jun 29 10:38:08 2020 -0700
Deprecated getCurrentBytes(boolean). Replaced by getCompactBytes() and
getCurrentBytes().
---
.../theta/ConcurrentHeapThetaBuffer.java | 5 +++++
.../java/org/apache/datasketches/theta/Sketch.java | 20 +++++++++++++-------
.../org/apache/datasketches/theta/UpdateSketch.java | 4 ++--
.../apache/datasketches/theta/CompactSketchTest.java | 2 --
.../theta/ConcurrentDirectQuickSelectSketchTest.java | 2 +-
.../theta/ConcurrentHeapQuickSelectSketchTest.java | 16 ++++++++--------
.../datasketches/theta/DirectIntersectionTest.java | 15 ++++++---------
.../theta/DirectQuickSelectSketchTest.java | 6 +++---
.../apache/datasketches/theta/DirectUnionTest.java | 19 +++++++++----------
.../datasketches/theta/HeapAlphaSketchTest.java | 16 ++++++++--------
.../datasketches/theta/HeapIntersectionTest.java | 17 +++++++----------
.../theta/HeapQuickSelectSketchTest.java | 18 +++++++++---------
.../org/apache/datasketches/theta/HeapUnionTest.java | 19 +++++++++----------
.../datasketches/theta/SingleItemSketchTest.java | 2 +-
.../org/apache/datasketches/theta/SketchTest.java | 16 ++++++++--------
.../apache/datasketches/theta/UpdateSketchTest.java | 13 ++++++-------
16 files changed, 95 insertions(+), 95 deletions(-)
diff --git a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java
index 64ce463..e4b18f2 100644
--- a/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java
+++ b/src/main/java/org/apache/datasketches/theta/ConcurrentHeapThetaBuffer.java
@@ -78,6 +78,11 @@ final class ConcurrentHeapThetaBuffer extends HeapQuickSelectSketch {
//Sketch overrides
@Override
+ public int getCompactBytes() {
+ return shared.getCompactBytes();
+ }
+
+ @Override
public int getCurrentBytes() {
return shared.getCurrentBytes();
}
diff --git a/src/main/java/org/apache/datasketches/theta/Sketch.java b/src/main/java/org/apache/datasketches/theta/Sketch.java
index eac37d0..aea0657 100644
--- a/src/main/java/org/apache/datasketches/theta/Sketch.java
+++ b/src/main/java/org/apache/datasketches/theta/Sketch.java
@@ -97,7 +97,7 @@ public abstract class Sketch {
* Wrap takes the sketch image in Memory and refers to it directly. There is no data copying onto
* the java heap. Only "Direct" Serialization Version 3 (i.e, OpenSource) sketches that have
* been explicitly stored as direct objects can be wrapped. This method assumes the
- * {@link Util#DEFAULT_UPDATE_SEED}.
+ * {@link org.apache.datasketches.Util#DEFAULT_UPDATE_SEED}.
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* @param srcMem an image of a Sketch where the image seed hash matches the default seed hash.
* <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@@ -250,6 +250,18 @@ public abstract class Sketch {
/**
* Returns the number of storage bytes required for this Sketch in its current state.
+ * @param compact if true, returns the bytes required for compact form.
+ * If this sketch is already in compact form this parameter is ignored.
+ * @return the number of storage bytes required for this sketch
+ * @deprecated use either {@link #getCompactBytes()} or {@link #getCurrentBytes()}.
+ */
+ @Deprecated
+ public int getCurrentBytes(final boolean compact) {
+ return compact ? getCompactBytes() : getCurrentBytes();
+ }
+
+ /**
+ * Returns the number of storage bytes required for this sketch in its current state.
*
* @return the number of storage bytes required for this sketch
*/
@@ -563,12 +575,6 @@ public abstract class Sketch {
abstract int getCurrentDataLongs();
- int getCurrentDataLongs(final boolean compact) {
- return (isCompact() || compact)
- ? getRetainedEntries(true)
- : (1 << ((UpdateSketch) this).getLgArrLongs());
- }
-
/**
* Returns preamble longs if stored in current state.
* @param compact if true, returns the preamble longs required for compact form.
diff --git a/src/main/java/org/apache/datasketches/theta/UpdateSketch.java b/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
index de519bf..bed93a5 100644
--- a/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
+++ b/src/main/java/org/apache/datasketches/theta/UpdateSketch.java
@@ -65,7 +65,7 @@ public abstract class UpdateSketch extends Sketch {
* Wrap takes the sketch image in Memory and refers to it directly. There is no data copying onto
* the java heap. Only "Direct" Serialization Version 3 (i.e, OpenSource) sketches that have
* been explicitly stored as direct objects can be wrapped. This method assumes the
- * {@link Util#DEFAULT_UPDATE_SEED}.
+ * {@link org.apache.datasketches.Util#DEFAULT_UPDATE_SEED}.
* <a href="{@docRoot}/resources/dictionary.html#defaultUpdateSeed">Default Update Seed</a>.
* @param srcMem an image of a Sketch where the image seed hash matches the default seed hash.
* <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
@@ -106,7 +106,7 @@ public abstract class UpdateSketch extends Sketch {
/**
* Instantiates an on-heap UpdateSketch from Memory. This method assumes the
- * {@link Util#DEFAULT_UPDATE_SEED}.
+ * {@link org.apache.datasketches.Util#DEFAULT_UPDATE_SEED}.
* @param srcMem <a href="{@docRoot}/resources/dictionary.html#mem">See Memory</a>
* @return an UpdateSketch
*/
diff --git a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
index a2807cb..502dd4b 100644
--- a/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/CompactSketchTest.java
@@ -185,7 +185,6 @@ public class CompactSketchTest {
public void checkMemTooSmall() {
int k = 512;
int u = k;
- boolean compact = true;
boolean ordered = false;
UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
@@ -202,7 +201,6 @@ public class CompactSketchTest {
public void checkMemTooSmallOrdered() {
int k = 512;
int u = k;
- boolean compact = true;
boolean ordered = true;
UpdateSketch usk = UpdateSketch.builder().setNominalEntries(k).build();
for (int i=0; i<u; i++) {
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
index 5bb93e8..4a8e836 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentDirectQuickSelectSketchTest.java
@@ -382,7 +382,7 @@ public class ConcurrentDirectQuickSelectSketchTest {
assertEquals(csk.isEstimationMode(), estimating);
assertEquals(csk.getClass().getSimpleName(), "HeapCompactSketch");
- int bytes = local.getCurrentBytes(); //TODO WHAT IS GOING ON HERE
+ int bytes = local.getCompactBytes(); //TODO WHAT IS GOING ON HERE
assertEquals(bytes, (k*8) + (Family.COMPACT.getMaxPreLongs() << 3));
byte[] memArr2 = new byte[bytes];
WritableMemory mem2 = WritableMemory.wrap(memArr2);
diff --git a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
index 61bd5be..e119dc5 100644
--- a/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/ConcurrentHeapQuickSelectSketchTest.java
@@ -296,8 +296,8 @@ public class ConcurrentHeapQuickSelectSketchTest {
double localEst = local.getEstimate();
double localLB = local.getLowerBound(2);
double localUB = local.getUpperBound(2);
- int localBytes = local.getCurrentBytes(false); //size stored as UpdateSketch
- int localCompBytes = local.getCurrentBytes(true); //size stored as CompactSketch
+ int localBytes = local.getCurrentBytes(); //size stored as UpdateSketch
+ int localCompBytes = local.getCompactBytes(); //size stored as CompactSketch
assertEquals(localBytes, maxBytes);
assertEquals(local.isEstimationMode(), estimating);
@@ -310,7 +310,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(comp1.getUpperBound(2), localUB);
assertEquals(comp1.isEmpty(), false);
assertEquals(comp1.isEstimationMode(), estimating);
- assertEquals(comp1.getCurrentBytes(true), localCompBytes);
+ assertEquals(comp1.getCompactBytes(), localCompBytes);
assertEquals(comp1.getClass().getSimpleName(), "HeapCompactSketch");
comp2 = shared.compact(true, null);
@@ -320,7 +320,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(comp2.getUpperBound(2), localUB);
assertEquals(comp2.isEmpty(), false);
assertEquals(comp2.isEstimationMode(), estimating);
- assertEquals(comp2.getCurrentBytes(true), localCompBytes);
+ assertEquals(comp2.getCompactBytes(), localCompBytes);
assertEquals(comp2.getClass().getSimpleName(), "HeapCompactSketch");
byte[] memArr2 = new byte[localCompBytes];
@@ -333,7 +333,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(comp3.getUpperBound(2), localUB);
assertEquals(comp3.isEmpty(), false);
assertEquals(comp3.isEstimationMode(), estimating);
- assertEquals(comp3.getCurrentBytes(true), localCompBytes);
+ assertEquals(comp3.getCompactBytes(), localCompBytes);
assertEquals(comp3.getClass().getSimpleName(), "DirectCompactSketch");
mem2.clear();
@@ -344,7 +344,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
assertEquals(comp4.getUpperBound(2), localUB);
assertEquals(comp4.isEmpty(), false);
assertEquals(comp4.isEstimationMode(), estimating);
- assertEquals(comp4.getCurrentBytes(true), localCompBytes);
+ assertEquals(comp4.getCompactBytes(), localCompBytes);
assertEquals(comp4.getClass().getSimpleName(), "DirectCompactSketch");
comp4.toString(false, true, 0, false);
}
@@ -368,7 +368,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
double localUB = local.getUpperBound(2);
//int currentUSBytes = local.getCurrentBytes(false);
//assertEquals(currentUSBytes, (32*8) + 24); // clumsy, but a function of RF and TCF
- int compBytes = local.getCurrentBytes(true); //compact form
+ int compBytes = local.getCompactBytes(); //compact form
assertEquals(compBytes, 8);
assertEquals(local.isEstimationMode(), estimating);
@@ -582,7 +582,7 @@ public class ConcurrentHeapQuickSelectSketchTest {
double uskUB = local.getUpperBound(2);
assertFalse(local.isEstimationMode());
- int bytes = local.getCurrentBytes(true); //compact form
+ int bytes = local.getCompactBytes(); //compact form
assertEquals(bytes, 8);
byte[] memArr2 = new byte[bytes];
WritableMemory mem2 = WritableMemory.wrap(memArr2);
diff --git a/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java b/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
index 2b2b76e..e794ac6 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectIntersectionTest.java
@@ -29,14 +29,13 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.Family;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.SketchesReadOnlyException;
import org.apache.datasketches.SketchesStateException;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.memory.WritableMemory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -83,8 +82,7 @@ public class DirectIntersectionTest {
rsk1 = inter.getResult(ordered, null);
assertEquals(rsk1.getEstimate(), 0.0);
- boolean compact = true;
- int bytes = rsk1.getCurrentBytes(compact);
+ int bytes = rsk1.getCompactBytes();
byte[] byteArray = new byte[bytes];
WritableMemory mem = WritableMemory.wrap(byteArray);
@@ -128,8 +126,7 @@ public class DirectIntersectionTest {
rsk1 = inter.getResult(ordered, null);
assertEquals(rsk1.getEstimate(), (double)k);
- boolean compact = true;
- int bytes = rsk1.getCurrentBytes(compact);
+ int bytes = rsk1.getCompactBytes();
byte[] byteArray = new byte[bytes];
WritableMemory mem = WritableMemory.wrap(byteArray);
@@ -720,7 +717,7 @@ public class DirectIntersectionTest {
Intersection inter = Sketches.setOperationBuilder().buildIntersection(iMem);
inter.update(sk);
CompactSketch csk = inter.getResult();
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
index d44625d..0eaf1e4 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectQuickSelectSketchTest.java
@@ -218,7 +218,7 @@ public class DirectQuickSelectSketchTest {
for (int i=0; i< k; i++) { usk.update(i); }
- int bytes = usk.getCurrentBytes(false);
+ int bytes = usk.getCurrentBytes();
byte[] byteArray = usk.toByteArray();
assertEquals(bytes, byteArray.length);
@@ -336,7 +336,7 @@ public class DirectQuickSelectSketchTest {
assertEquals(csk.isEstimationMode(), estimating);
assertEquals(csk.getClass().getSimpleName(), "HeapCompactSketch");
- int bytes = usk.getCurrentBytes(true);
+ int bytes = usk.getCompactBytes();
assertEquals(bytes, (k*8) + (Family.COMPACT.getMaxPreLongs() << 3));
byte[] memArr2 = new byte[bytes];
WritableMemory mem2 = WritableMemory.wrap(memArr2);
@@ -377,7 +377,7 @@ public class DirectQuickSelectSketchTest {
double uskUB = usk.getUpperBound(2);
assertEquals(usk.isEstimationMode(), false);
- int bytes = usk.getCurrentBytes(true); //compact form
+ int bytes = usk.getCompactBytes(); //compact form
assertEquals(bytes, 8);
byte[] memArr2 = new byte[bytes];
WritableMemory mem2 = WritableMemory.wrap(memArr2);
diff --git a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
index 840d2de..0975b40 100644
--- a/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/DirectUnionTest.java
@@ -19,25 +19,24 @@
package org.apache.datasketches.theta;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.theta.BackwardConversions.convertSerVer3toSerVer1;
import static org.apache.datasketches.theta.BackwardConversions.convertSerVer3toSerVer2;
import static org.apache.datasketches.theta.HeapUnionTest.testAllCompactForms;
import static org.apache.datasketches.theta.PreambleUtil.SER_VER_BYTE;
import static org.apache.datasketches.theta.SetOperation.getMaxUnionBytes;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Arrays;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.Family;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.Util;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.memory.WritableMemory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -271,7 +270,7 @@ public class DirectUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
CompactSketch cosk2 = usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
WritableMemory uMem = WritableMemory.wrap(new byte[getMaxUnionBytes(k)]); //union memory
@@ -311,7 +310,7 @@ public class DirectUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
WritableMemory uMem = WritableMemory.wrap(new byte[getMaxUnionBytes(k)]); //union memory
@@ -351,7 +350,7 @@ public class DirectUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
usk2.compact(false, cskMem2); //unordered, loads the cskMem2 as unordered
WritableMemory uMem = WritableMemory.wrap(new byte[getMaxUnionBytes(k)]); //union memory
@@ -683,7 +682,7 @@ public class DirectUnionTest {
Union union = Sketches.setOperationBuilder().setNominalEntries(k).buildUnion(iMem);
union.update(sk);
CompactSketch csk = union.getResult();
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test
@@ -795,7 +794,7 @@ public class DirectUnionTest {
usk.update(Integer.toString(i));
}
usk.rebuild(); //optional but created the symptom
- final WritableMemory memIn = WritableMemory.allocate(usk.getCurrentBytes(true));
+ final WritableMemory memIn = WritableMemory.allocate(usk.getCompactBytes());
usk.compact(true, memIn); //side effect of loading the memIn
//create empty target union in off-heap mem
diff --git a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
index 62ff8ef..c77ff8d 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapAlphaSketchTest.java
@@ -140,7 +140,7 @@ public class HeapAlphaSketchTest {
usk.update(i);
}
- int bytes = usk.getCurrentBytes(false);
+ int bytes = usk.getCurrentBytes();
byte[] byteArray = usk.toByteArray();
assertEquals(bytes, byteArray.length);
@@ -245,8 +245,8 @@ public class HeapAlphaSketchTest {
double comp1est = comp1.getEstimate();
double comp1lb = comp1.getLowerBound(2);
double comp1ub = comp1.getUpperBound(2);
- int comp1bytes = comp1.getCurrentBytes(true);
- assertEquals(comp1bytes, comp1.getCurrentBytes(false));
+ int comp1bytes = comp1.getCompactBytes();
+ assertEquals(comp1bytes, comp1.getCurrentBytes());
int comp1curCount = comp1.getRetainedEntries(true); //flag is not relevant
assertEquals(comp1bytes, (comp1curCount << 3) + (Family.COMPACT.getMaxPreLongs() << 3));
@@ -261,11 +261,11 @@ public class HeapAlphaSketchTest {
assertEquals(comp2.getUpperBound(2), comp1ub);
assertEquals(comp2.isEmpty(), false);
assertEquals(comp2.isEstimationMode(), estimating);
- assertEquals(comp1bytes, comp2.getCurrentBytes(true)); //flag is not relevant
+ assertEquals(comp1bytes, comp2.getCompactBytes()); //flag is not relevant
assertEquals(comp1curCount, comp2.getRetainedEntries(true)); //flag is not relevant
assertEquals(comp2.getClass().getSimpleName(), "HeapCompactSketch");
- int bytes = usk.getCurrentBytes(true);
+ int bytes = usk.getCompactBytes();
int alphaBytes = sk1.getRetainedEntries(true) * 8;
assertEquals(bytes, alphaBytes + (Family.COMPACT.getMaxPreLongs() << 3));
byte[] memArr2 = new byte[bytes];
@@ -278,7 +278,7 @@ public class HeapAlphaSketchTest {
assertEquals(comp3.getUpperBound(2), comp1ub);
assertEquals(comp3.isEmpty(), false);
assertEquals(comp3.isEstimationMode(), estimating);
- assertEquals(comp1bytes, comp3.getCurrentBytes(true)); //flag is not relevant
+ assertEquals(comp1bytes, comp3.getCompactBytes()); //flag is not relevant
assertEquals(comp1curCount, comp3.getRetainedEntries(true)); //flag is not relevant
assertEquals(comp3.getClass().getSimpleName(), "DirectCompactSketch");
@@ -290,7 +290,7 @@ public class HeapAlphaSketchTest {
assertEquals(comp4.getUpperBound(2), comp1ub);
assertEquals(comp4.isEmpty(), false);
assertEquals(comp4.isEstimationMode(), estimating);
- assertEquals(comp1bytes, comp4.getCurrentBytes(true)); //flag is not relevant
+ assertEquals(comp1bytes, comp4.getCompactBytes()); //flag is not relevant
assertEquals(comp1curCount, comp4.getRetainedEntries(true)); //flag is not relevant
assertEquals(comp4.getClass().getSimpleName(), "DirectCompactSketch");
}
@@ -310,7 +310,7 @@ public class HeapAlphaSketchTest {
double uskUB = usk.getUpperBound(2);
assertEquals(usk.isEstimationMode(), estimating);
- int bytes = usk.getCurrentBytes(true);
+ int bytes = usk.getCompactBytes();
assertEquals(bytes, 8); //compact, empty and theta = 1.0
byte[] memArr2 = new byte[bytes];
WritableMemory mem2 = WritableMemory.wrap(memArr2);
diff --git a/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java b/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
index cdb1f9e..4008203 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapIntersectionTest.java
@@ -27,13 +27,12 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.Family;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.SketchesStateException;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.memory.WritableMemory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -71,8 +70,7 @@ public class HeapIntersectionTest {
rsk1 = inter.getResult(ordered, null);
assertEquals(rsk1.getEstimate(), 0.0);
- boolean compact = true;
- int bytes = rsk1.getCurrentBytes(compact);
+ int bytes = rsk1.getCompactBytes();
byte[] byteArray = new byte[bytes];
WritableMemory mem = WritableMemory.wrap(byteArray);
@@ -114,8 +112,7 @@ public class HeapIntersectionTest {
rsk1 = inter.getResult(ordered, null);
assertEquals(rsk1.getEstimate(), (double)k);
- boolean compact = true;
- int bytes = rsk1.getCurrentBytes(compact);
+ int bytes = rsk1.getCompactBytes();
byte[] byteArray = new byte[bytes];
WritableMemory mem = WritableMemory.wrap(byteArray);
@@ -561,7 +558,7 @@ public class HeapIntersectionTest {
Intersection inter = Sketches.setOperationBuilder().buildIntersection();
inter.update(sk);
CompactSketch csk = inter.getResult();
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test
@@ -576,7 +573,7 @@ public class HeapIntersectionTest {
UpdateSketch skB = Sketches.updateSketchBuilder().build();
Intersection inter = Sketches.setOperationBuilder().buildIntersection();
CompactSketch csk = inter.intersect(skA, skB);
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test
diff --git a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
index c230a88..74a312f 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapQuickSelectSketchTest.java
@@ -133,7 +133,7 @@ public class HeapQuickSelectSketchTest {
usk.update(i);
}
- int bytes = usk.getCurrentBytes(false);
+ int bytes = usk.getCurrentBytes();
byte[] byteArray = usk.toByteArray();
assertEquals(bytes, byteArray.length);
@@ -236,8 +236,8 @@ public class HeapQuickSelectSketchTest {
double uskEst = usk.getEstimate();
double uskLB = usk.getLowerBound(2);
double uskUB = usk.getUpperBound(2);
- int uskBytes = usk.getCurrentBytes(false); //size stored as UpdateSketch
- int uskCompBytes = usk.getCurrentBytes(true); //size stored as CompactSketch
+ int uskBytes = usk.getCurrentBytes(); //size stored as UpdateSketch
+ int uskCompBytes = usk.getCompactBytes(); //size stored as CompactSketch
assertEquals(uskBytes, maxBytes);
assertEquals(usk.isEstimationMode(), estimating);
@@ -250,7 +250,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(comp1.getUpperBound(2), uskUB);
assertEquals(comp1.isEmpty(), false);
assertEquals(comp1.isEstimationMode(), estimating);
- assertEquals(comp1.getCurrentBytes(true), uskCompBytes);
+ assertEquals(comp1.getCompactBytes(), uskCompBytes);
assertEquals(comp1.getClass().getSimpleName(), "HeapCompactSketch");
comp2 = usk.compact(true, null);
@@ -260,7 +260,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(comp2.getUpperBound(2), uskUB);
assertEquals(comp2.isEmpty(), false);
assertEquals(comp2.isEstimationMode(), estimating);
- assertEquals(comp2.getCurrentBytes(true), uskCompBytes);
+ assertEquals(comp2.getCompactBytes(), uskCompBytes);
assertEquals(comp2.getClass().getSimpleName(), "HeapCompactSketch");
byte[] memArr2 = new byte[uskCompBytes];
@@ -273,7 +273,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(comp3.getUpperBound(2), uskUB);
assertEquals(comp3.isEmpty(), false);
assertEquals(comp3.isEstimationMode(), estimating);
- assertEquals(comp3.getCurrentBytes(true), uskCompBytes);
+ assertEquals(comp3.getCompactBytes(), uskCompBytes);
assertEquals(comp3.getClass().getSimpleName(), "DirectCompactSketch");
mem2.clear();
@@ -284,7 +284,7 @@ public class HeapQuickSelectSketchTest {
assertEquals(comp4.getUpperBound(2), uskUB);
assertEquals(comp4.isEmpty(), false);
assertEquals(comp4.isEstimationMode(), estimating);
- assertEquals(comp4.getCurrentBytes(true), uskCompBytes);
+ assertEquals(comp4.getCompactBytes(), uskCompBytes);
assertEquals(comp4.getClass().getSimpleName(), "DirectCompactSketch");
comp4.toString(false, true, 0, false);
}
@@ -303,9 +303,9 @@ public class HeapQuickSelectSketchTest {
double uskEst = usk.getEstimate();
double uskLB = usk.getLowerBound(2);
double uskUB = usk.getUpperBound(2);
- int currentUSBytes = usk.getCurrentBytes(false);
+ int currentUSBytes = usk.getCurrentBytes();
assertEquals(currentUSBytes, (32*8) + 24); // clumsy, but a function of RF and TCF
- int compBytes = usk.getCurrentBytes(true); //compact form
+ int compBytes = usk.getCompactBytes(); //compact form
assertEquals(compBytes, 8);
assertEquals(usk.isEstimationMode(), estimating);
diff --git a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
index fcacb03..138112e 100644
--- a/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
+++ b/src/test/java/org/apache/datasketches/theta/HeapUnionTest.java
@@ -19,22 +19,21 @@
package org.apache.datasketches.theta;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.theta.BackwardConversions.convertSerVer3toSerVer1;
import static org.apache.datasketches.theta.BackwardConversions.convertSerVer3toSerVer2;
import static org.apache.datasketches.theta.PreambleUtil.SER_VER_BYTE;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import java.util.Arrays;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.Family;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.Util;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.memory.WritableMemory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -230,7 +229,7 @@ public class HeapUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
CompactSketch cosk2 = usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
@@ -269,7 +268,7 @@ public class HeapUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
usk2.compact(true, cskMem2); //ordered, loads the cskMem2 as ordered
Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
@@ -308,7 +307,7 @@ public class HeapUnionTest {
usk2.update(i); //2k no overlap, exact, will force early stop
}
- WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCurrentBytes(true)]);
+ WritableMemory cskMem2 = WritableMemory.wrap(new byte[usk2.getCompactBytes()]);
usk2.compact(false, cskMem2); //unordered, loads the cskMem2 as unordered
Union union = SetOperation.builder().setNominalEntries(k).buildUnion();
@@ -562,7 +561,7 @@ public class HeapUnionTest {
Union union = Sketches.setOperationBuilder().setNominalEntries(k).buildUnion();
union.update(sk);
CompactSketch csk = union.getResult();
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test
@@ -626,7 +625,7 @@ public class HeapUnionTest {
compEst2 = comp2.getEstimate();
assertEquals(compEst2, compEst1, 0.0);
- WritableMemory mem = WritableMemory.wrap(new byte[comp2.getCurrentBytes(false)]);
+ WritableMemory mem = WritableMemory.wrap(new byte[comp2.getCurrentBytes()]);
compEst2 = union.getResult(false, mem).getEstimate(); //not ordered, mem
assertEquals(compEst2, compEst1, 0.0);
diff --git a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
index dbbc6ff..d2fa4db 100644
--- a/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SingleItemSketchTest.java
@@ -122,7 +122,7 @@ public class SingleItemSketchTest {
@Test
public void checkSketchInterface() {
SingleItemSketch sis = SingleItemSketch.create(1);
- assertEquals(sis.getCurrentBytes(true), 16);
+ assertEquals(sis.getCompactBytes(), 16);
assertEquals(sis.getEstimate(), 1.0);
assertEquals(sis.getLowerBound(1), 1.0);
assertEquals(sis.getRetainedEntries(true), 1);
diff --git a/src/test/java/org/apache/datasketches/theta/SketchTest.java b/src/test/java/org/apache/datasketches/theta/SketchTest.java
index 840b31e..fa11112 100644
--- a/src/test/java/org/apache/datasketches/theta/SketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/SketchTest.java
@@ -68,12 +68,12 @@ public class SketchTest {
assertEquals(sketch.getCurrentPreambleLongs(false), lowQSPreLongs);
assertEquals(sketch.getCurrentPreambleLongs(true), 1); //compact form
assertEquals(sketch.getCurrentDataLongs(), k*2);
- assertEquals(sketch.getCurrentBytes(false), (k*2*8) + (lowQSPreLongs << 3));
- assertEquals(sketch.getCurrentBytes(true), lowCompPreLongs << 3);
+ assertEquals(sketch.getCurrentBytes(), (k*2*8) + (lowQSPreLongs << 3));
+ assertEquals(sketch.getCompactBytes(), lowCompPreLongs << 3);
CompactSketch compSk = sketch.compact(false, null);
- assertEquals(compSk.getCurrentBytes(true), 8);
- assertEquals(compSk.getCurrentBytes(false), 8);
+ assertEquals(compSk.getCompactBytes(), 8);
+ assertEquals(compSk.getCurrentBytes(), 8);
assertEquals(compSk.getCurrentDataLongs(), 0);
int compPreLongs = computeCompactPreLongs(sketch.isEmpty(), sketch.getRetainedEntries(true),
@@ -87,8 +87,8 @@ public class SketchTest {
assertEquals(sketch.getCurrentPreambleLongs(false), lowQSPreLongs);
assertEquals(sketch.getCurrentPreambleLongs(true), 2); //compact form
assertEquals(sketch.getCurrentDataLongs(), k*2);
- assertEquals(sketch.getCurrentBytes(false), (k*2*8) + (lowQSPreLongs << 3));
- assertEquals(sketch.getCurrentBytes(true), (k*8) + (2*8)); //compact form //FAILS HERE
+ assertEquals(sketch.getCurrentBytes(), (k*2*8) + (lowQSPreLongs << 3));
+ assertEquals(sketch.getCompactBytes(), (k*8) + (2*8)); //compact form //FAILS HERE
compPreLongs = computeCompactPreLongs(sketch.isEmpty(), sketch.getRetainedEntries(true),
sketch.getThetaLong());
@@ -102,8 +102,8 @@ public class SketchTest {
assertEquals(sketch.getCurrentPreambleLongs(false), lowQSPreLongs);
assertEquals(sketch.getCurrentPreambleLongs(true), 3); //compact form
assertEquals(sketch.getCurrentDataLongs(), k*2);
- assertEquals(sketch.getCurrentBytes(false), (k*2*8) + (lowQSPreLongs << 3));
- assertEquals(sketch.getCurrentBytes(true), (curCount*8) + (3*8)); //compact form
+ assertEquals(sketch.getCurrentBytes(), (k*2*8) + (lowQSPreLongs << 3));
+ assertEquals(sketch.getCompactBytes(), (curCount*8) + (3*8)); //compact form
compPreLongs = computeCompactPreLongs(sketch.isEmpty(), sketch.getRetainedEntries(true),
sketch.getThetaLong());
diff --git a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
index c5bb6c2..0b5d9da 100644
--- a/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
+++ b/src/test/java/org/apache/datasketches/theta/UpdateSketchTest.java
@@ -19,22 +19,21 @@
package org.apache.datasketches.theta;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.datasketches.Util.DEFAULT_UPDATE_SEED;
import static org.apache.datasketches.theta.PreambleUtil.PREAMBLE_LONGS_BYTE;
import static org.apache.datasketches.theta.PreambleUtil.SER_VER_BYTE;
-import static java.nio.charset.StandardCharsets.UTF_8;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.DefaultMemoryRequestServer;
-import org.apache.datasketches.memory.MemoryRequestServer;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.Family;
import org.apache.datasketches.ResizeFactor;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.Util;
+import org.apache.datasketches.memory.DefaultMemoryRequestServer;
+import org.apache.datasketches.memory.MemoryRequestServer;
+import org.apache.datasketches.memory.WritableMemory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -147,7 +146,7 @@ public class UpdateSketchTest {
public void checkCompact() {
UpdateSketch sk = Sketches.updateSketchBuilder().build();
CompactSketch csk = sk.compact();
- assertEquals(csk.getCurrentBytes(true), 8);
+ assertEquals(csk.getCompactBytes(), 8);
}
@Test(expectedExceptions = SketchesArgumentException.class)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org