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 2019/11/30 23:48:37 UTC
[incubator-datasketches-java] 02/02: Adding finals to many test
files.
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch Cleanup
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-java.git
commit c0819b9d5e1ca4f01d4b78d10e14ccead3cf63a3
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Sat Nov 30 15:46:52 2019 -0800
Adding finals to many test files.
Finally decided to omit test files from checkstyle checking.
---
.../org/apache/datasketches/cpc/BitMatrix.java | 0
.../cpc/CompressionCharacterization.java | 5 +
.../apache/datasketches/cpc/MergingValidation.java | 57 +++----
.../datasketches/cpc/QuickMergingValidation.java | 69 +++++----
.../datasketches/cpc/StreamingValidation.java | 41 ++---
.../java/org/apache/datasketches/cpc/TestUtil.java | 18 +--
.../apache/datasketches/cpc/CpcCBinariesTest.java | 166 ++++++++++-----------
.../datasketches/cpc/CpcCompressionTest.java | 44 +++---
.../org/apache/datasketches/cpc/CpcSketchTest.java | 51 ++++---
.../{LzTzSpeedTesting.java => LzTzSpeedTest.java} | 5 +-
.../org/apache/datasketches/cpc/TestAllTest.java | 20 +--
...ressTestHashMap.java => HashMapStressTest.java} | 24 +--
.../datasketches/theta/BackwardConversions.java | 36 ++---
.../org/apache/datasketches/tuple/TestUtil.java | 14 +-
.../tuple/aninteger/EngagementTest.java | 2 +-
tools/SketchesCheckstyle.xml | 6 +-
16 files changed, 291 insertions(+), 267 deletions(-)
diff --git a/src/test/java/org/apache/datasketches/cpc/BitMatrix.java b/src/main/java/org/apache/datasketches/cpc/BitMatrix.java
similarity index 100%
rename from src/test/java/org/apache/datasketches/cpc/BitMatrix.java
rename to src/main/java/org/apache/datasketches/cpc/BitMatrix.java
diff --git a/src/test/java/org/apache/datasketches/cpc/CompressionCharacterization.java b/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java
similarity index 97%
rename from src/test/java/org/apache/datasketches/cpc/CompressionCharacterization.java
rename to src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java
index 10c8f63..dd61744 100644
--- a/src/test/java/org/apache/datasketches/cpc/CompressionCharacterization.java
+++ b/src/main/java/org/apache/datasketches/cpc/CompressionCharacterization.java
@@ -34,6 +34,11 @@ import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableMemory;
/**
+ * This code is used both by unit tests, for short running tests,
+ * and by the characterization repository for longer running, more exhaustive testing. To be
+ * accessible for both, this code is part of the main hierarchy. It is not used during normal
+ * production runtime.
+ *
* @author Lee Rhodes
* @author Kevin Lang
*/
diff --git a/src/test/java/org/apache/datasketches/cpc/MergingValidation.java b/src/main/java/org/apache/datasketches/cpc/MergingValidation.java
similarity index 75%
rename from src/test/java/org/apache/datasketches/cpc/MergingValidation.java
rename to src/main/java/org/apache/datasketches/cpc/MergingValidation.java
index fae641a..ced5cea 100644
--- a/src/test/java/org/apache/datasketches/cpc/MergingValidation.java
+++ b/src/main/java/org/apache/datasketches/cpc/MergingValidation.java
@@ -29,6 +29,11 @@ import java.io.PrintStream;
import java.io.PrintWriter;
/**
+ * This code is used both by unit tests, for short running tests,
+ * and by the characterization repository for longer running, more exhaustive testing. To be
+ * accessible for both, this code is part of the main hierarchy. It is not used during normal
+ * production runtime.
+ *
* @author Lee Rhodes
* @author Kevin Lang
*/
@@ -48,8 +53,8 @@ public class MergingValidation {
private PrintStream printStream;
private PrintWriter printWriter;
- public MergingValidation(int lgMinK, int lgMaxK, int lgMulK, int uPPO, int incLgK,
- PrintStream pS, PrintWriter pW) {
+ public MergingValidation(final int lgMinK, final int lgMaxK, final int lgMulK, final int uPPO,
+ final int incLgK, final PrintStream pS, final PrintWriter pW) {
this.lgMinK = lgMinK;
this.lgMaxK = lgMaxK;
this.lgMulK = lgMulK;
@@ -97,18 +102,18 @@ public class MergingValidation {
private void testMerging(final int lgKm, final int lgKa, final int lgKb, final long nA,
final long nB) {
- CpcUnion ugM = new CpcUnion(lgKm);
+ final CpcUnion ugM = new CpcUnion(lgKm);
-// int lgKd = ((nA != 0) && (lgKa < lgKm)) ? lgKa : lgKm;
-// lgKd = ((nB != 0) && (lgKb < lgKd)) ? lgKb : lgKd;
+ // int lgKd = ((nA != 0) && (lgKa < lgKm)) ? lgKa : lgKm;
+ // lgKd = ((nB != 0) && (lgKb < lgKd)) ? lgKb : lgKd;
int lgKd = lgKm;
if ((lgKa < lgKd) && (nA != 0)) { lgKd = lgKa; } //d = min(a,m) : m
if ((lgKb < lgKd) && (nB != 0)) { lgKd = lgKb; } //d = min(b,d) : d
- CpcSketch skD = new CpcSketch(lgKd); // direct sketch, updated with both streams
+ final CpcSketch skD = new CpcSketch(lgKd); // direct sketch, updated with both streams
- CpcSketch skA = new CpcSketch(lgKa);
- CpcSketch skB = new CpcSketch(lgKb);
+ final CpcSketch skA = new CpcSketch(lgKa);
+ final CpcSketch skB = new CpcSketch(lgKb);
for (long i = 0; i < nA; i++) {
final long in = (vIn += iGoldenU64);
@@ -129,16 +134,16 @@ public class MergingValidation {
final long cM = ugM.getNumCoupons();//countBitsSetInMatrix(matrixM);
final long cD = skD.numCoupons;
- Flavor flavorD = skD.getFlavor();
- Flavor flavorA = skA.getFlavor();
- Flavor flavorB = skB.getFlavor();
- String dOff = Integer.toString(skD.windowOffset);
- String aOff = Integer.toString(skA.windowOffset);
- String bOff = Integer.toString(skB.windowOffset);
- String flavorDoff = flavorD + String.format("%2s",dOff);
- String flavorAoff = flavorA + String.format("%2s",aOff);
- String flavorBoff = flavorB + String.format("%2s",bOff);
- double iconEstD = getIconEstimate(lgKd, cD);
+ final Flavor flavorD = skD.getFlavor();
+ final Flavor flavorA = skA.getFlavor();
+ final Flavor flavorB = skB.getFlavor();
+ final String dOff = Integer.toString(skD.windowOffset);
+ final String aOff = Integer.toString(skA.windowOffset);
+ final String bOff = Integer.toString(skB.windowOffset);
+ final String flavorDoff = flavorD + String.format("%2s",dOff);
+ final String flavorAoff = flavorA + String.format("%2s",aOff);
+ final String flavorBoff = flavorB + String.format("%2s",bOff);
+ final double iconEstD = getIconEstimate(lgKd, cD);
rtAssert(finalLgKm <= lgKm);
rtAssert(cM <= (skA.numCoupons + skB.numCoupons));
@@ -148,8 +153,8 @@ public class MergingValidation {
final long[] matrixD = CpcUtil.bitMatrixOfSketch(skD);
rtAssertEquals(matrixM, matrixD);
- CpcSketch skR = ugM.getResult();
- double iconEstR = getIconEstimate(skR.lgK, skR.numCoupons);
+ final CpcSketch skR = ugM.getResult();
+ final double iconEstR = getIconEstimate(skR.lgK, skR.numCoupons);
rtAssertEquals(iconEstD, iconEstR, 0.0);
rtAssert(TestUtil.specialEquals(skD, skR, false, true));
@@ -158,13 +163,13 @@ public class MergingValidation {
skA.numCoupons, skB.numCoupons, cD, iconEstR);
}
- private void printf(String format, Object ... args) {
+ private void printf(final String format, final Object ... args) {
if (printStream != null) { printStream.printf(format, args); }
if (printWriter != null) { printWriter.printf(format, args); }
}
private void assembleFormats() {
- String[][] assy = {
+ final String[][] assy = {
{"lgKm", "%4s", "%4d"},
{"lgKa", "%4s", "%4d"},
{"lgKb", "%4s", "%4d"},
@@ -180,13 +185,13 @@ public class MergingValidation {
{"Coupons_fd", "%9s", "%9d"},
{"IconEst_dr", "%12s", "%,12.0f"}
};
- int cols = assy.length;
+ final int cols = assy.length;
hStrArr = new String[cols];
- StringBuilder headerFmt = new StringBuilder();
- StringBuilder dataFmt = new StringBuilder();
+ final StringBuilder headerFmt = new StringBuilder();
+ final StringBuilder dataFmt = new StringBuilder();
headerFmt.append("\nMerging Validation\n");
for (int i = 0; i < cols; i++) {
- hStrArr[i] =assy[i][0];
+ hStrArr[i] = assy[i][0];
headerFmt.append(assy[i][1]);
headerFmt.append((i < (cols - 1)) ? "\t" : "\n");
dataFmt.append(assy[i][2]);
diff --git a/src/test/java/org/apache/datasketches/cpc/QuickMergingValidation.java b/src/main/java/org/apache/datasketches/cpc/QuickMergingValidation.java
similarity index 66%
rename from src/test/java/org/apache/datasketches/cpc/QuickMergingValidation.java
rename to src/main/java/org/apache/datasketches/cpc/QuickMergingValidation.java
index 9e1dc51..022dc88 100644
--- a/src/test/java/org/apache/datasketches/cpc/QuickMergingValidation.java
+++ b/src/main/java/org/apache/datasketches/cpc/QuickMergingValidation.java
@@ -26,8 +26,13 @@ import java.io.PrintStream;
import java.io.PrintWriter;
/**
- * This test of merging is the equal K case and is less exhaustive than TestAlltest
- * but is more practical for large values of K.
+ * This code is used both by unit tests, for short running tests,
+ * and by the characterization repository for longer running, more exhaustive testing. To be
+ * accessible for both, this code is part of the main hierarchy. It is not used during normal
+ * production runtime.
+ *
+ * <p>This test of merging is the equal K case and is less exhaustive than TestAlltest
+ * but is more practical for large values of K.</p>
*
* @author Lee Rhodes
* @author Kevin Lang
@@ -67,10 +72,10 @@ public class QuickMergingValidation {
}
}
- private void multiQuickTest(int lgK) {
- int k = 1 << lgK;
- int[] targetC = new int[] { 0, 1, ((3 * k) / 32) - 1, k / 3, k, (7 * k) / 2 };
- int len = targetC.length;
+ private void multiQuickTest(final int lgK) {
+ final int k = 1 << lgK;
+ final int[] targetC = new int[] { 0, 1, ((3 * k) / 32) - 1, k / 3, k, (7 * k) / 2 };
+ final int len = targetC.length;
for (int i = 0; i < len; i++) {
for (int j = 0; j < len; j++) {
quickTest(lgK, targetC[i], targetC[j]);
@@ -79,11 +84,11 @@ public class QuickMergingValidation {
}
void quickTest(final int lgK, final long cA, final long cB) {
- CpcSketch skA = new CpcSketch(lgK);
- CpcSketch skB = new CpcSketch(lgK);
- CpcSketch skD = new CpcSketch(lgK); // direct sketch
+ final CpcSketch skA = new CpcSketch(lgK);
+ final CpcSketch skB = new CpcSketch(lgK);
+ final CpcSketch skD = new CpcSketch(lgK); // direct sketch
- long t0, t1, t2, t3, t4, t5;
+ final long t0, t1, t2, t3, t4, t5;
t0 = System.nanoTime();
while (skA.numCoupons < cA) {
@@ -99,44 +104,44 @@ public class QuickMergingValidation {
}
t2 = System.nanoTime();
- CpcUnion ugM = new CpcUnion(lgK);
+ final CpcUnion ugM = new CpcUnion(lgK);
ugM.update(skA);
t3 = System.nanoTime();
ugM.update(skB);
t4 = System.nanoTime();
- CpcSketch skR = ugM.getResult();
+ final CpcSketch skR = ugM.getResult();
t5 = System.nanoTime();
rtAssert(TestUtil.specialEquals(skD, skR, false, true));
- Flavor fA = skA.getFlavor();
- Flavor fB = skB.getFlavor();
- Flavor fR = skR.getFlavor();
- String aOff = Integer.toString(skA.windowOffset);
- String bOff = Integer.toString(skB.windowOffset);
- String rOff = Integer.toString(skR.windowOffset);
- String fAoff = fA + String.format("%2s",aOff);
- String fBoff = fB + String.format("%2s",bOff);
- String fRoff = fR + String.format("%2s",rOff);
- double updA_mS = (t1 - t0) / 2E6; //update A,D to cA
- double updB_mS = (t2 - t1) / 2E6; //update B,D to cB
- double mrgA_mS = (t3 - t2) / 1E6; //merge A
- double mrgB_mS = (t4 - t3) / 1E6; //merge B
- double rslt_mS = (t5 - t4) / 1E6; //get Result
+ final Flavor fA = skA.getFlavor();
+ final Flavor fB = skB.getFlavor();
+ final Flavor fR = skR.getFlavor();
+ final String aOff = Integer.toString(skA.windowOffset);
+ final String bOff = Integer.toString(skB.windowOffset);
+ final String rOff = Integer.toString(skR.windowOffset);
+ final String fAoff = fA + String.format("%2s",aOff);
+ final String fBoff = fB + String.format("%2s",bOff);
+ final String fRoff = fR + String.format("%2s",rOff);
+ final double updA_mS = (t1 - t0) / 2E6; //update A,D to cA
+ final double updB_mS = (t2 - t1) / 2E6; //update B,D to cB
+ final double mrgA_mS = (t3 - t2) / 1E6; //merge A
+ final double mrgB_mS = (t4 - t3) / 1E6; //merge B
+ final double rslt_mS = (t5 - t4) / 1E6; //get Result
printf(dfmt, lgK, cA, cB, fAoff, fBoff, fRoff,
updA_mS, updB_mS, mrgA_mS, mrgB_mS, rslt_mS);
}
- private void printf(String format, Object ... args) {
+ private void printf(final String format, final Object ... args) {
if (printStream != null) { printStream.printf(format, args); }
if (printWriter != null) { printWriter.printf(format, args); }
}
private void assembleFormats() {
- String[][] assy = {
+ final String[][] assy = {
{"lgK", "%3s", "%3d"},
{"Ca", "%10s", "%10d"},
{"Cb", "%10s", "%10d"},
@@ -149,13 +154,13 @@ public class QuickMergingValidation {
{"mrgB_mS", "%9s", "%9.3f"},
{"rslt_mS", "%9s", "%9.3f"}
};
- int cols = assy.length;
+ final int cols = assy.length;
hStrArr = new String[cols];
- StringBuilder headerFmt = new StringBuilder();
- StringBuilder dataFmt = new StringBuilder();
+ final StringBuilder headerFmt = new StringBuilder();
+ final StringBuilder dataFmt = new StringBuilder();
headerFmt.append("\nQuick Merging Validation\n");
for (int i = 0; i < cols; i++) {
- hStrArr[i] =assy[i][0];
+ hStrArr[i] = assy[i][0];
headerFmt.append(assy[i][1]);
headerFmt.append((i < (cols - 1)) ? "\t" : "\n");
dataFmt.append(assy[i][2]);
diff --git a/src/test/java/org/apache/datasketches/cpc/StreamingValidation.java b/src/main/java/org/apache/datasketches/cpc/StreamingValidation.java
similarity index 76%
rename from src/test/java/org/apache/datasketches/cpc/StreamingValidation.java
rename to src/main/java/org/apache/datasketches/cpc/StreamingValidation.java
index 4a883fe..6e9c9ef 100644
--- a/src/test/java/org/apache/datasketches/cpc/StreamingValidation.java
+++ b/src/main/java/org/apache/datasketches/cpc/StreamingValidation.java
@@ -27,6 +27,11 @@ import java.io.PrintStream;
import java.io.PrintWriter;
/**
+ * This code is used both by unit tests, for short running tests,
+ * and by the characterization repository for longer running, more exhaustive testing. To be
+ * accessible for both, this code is part of the main hierarchy. It is not used during normal
+ * production runtime.
+ *
* @author Lee Rhodes
* @author Kevin Lang
*/
@@ -50,8 +55,8 @@ public class StreamingValidation {
private CpcSketch sketch = null;
private BitMatrix matrix = null;
- public StreamingValidation(int lgMinK, int lgMaxK, int trials, int ppoN, PrintStream pS,
- PrintWriter pW) {
+ public StreamingValidation(final int lgMinK, final int lgMaxK, final int trials, final int ppoN,
+ final PrintStream pS, final PrintWriter pW) {
this.lgMinK = lgMinK;
this.lgMaxK = lgMaxK;
this.trials = trials;
@@ -72,9 +77,9 @@ public class StreamingValidation {
}
}
- private void doRangeOfNAtLgK(int lgK) {
+ private void doRangeOfNAtLgK(final int lgK) {
long n = 1;
- long maxN = 64L * (1L << lgK); //1200
+ final long maxN = 64L * (1L << lgK); //1200
while (n < maxN) {
doTrialsAtLgKAtN(lgK, n);
n = Math.round(pwrLawNextDouble(ppoN, n, true, 2.0));
@@ -86,7 +91,7 @@ public class StreamingValidation {
* @param lgK the configured lgK
* @param n the current value of n
*/
- private void doTrialsAtLgKAtN(int lgK, long n) {
+ private void doTrialsAtLgKAtN(final int lgK, final long n) {
double sumC = 0.0;
double sumIconEst = 0.0;
double sumHipEst = 0.0;
@@ -105,25 +110,25 @@ public class StreamingValidation {
sumIconEst += IconEstimator.getIconEstimate(lgK, sketch.numCoupons);
sumHipEst += sketch.hipEstAccum;
rtAssertEquals(sketch.numCoupons, matrix.getNumCoupons());
- long[] bitMatrix = CpcUtil.bitMatrixOfSketch (sketch);
+ final long[] bitMatrix = CpcUtil.bitMatrixOfSketch(sketch);
rtAssertEquals(bitMatrix, matrix.getMatrix());
}
- long finC = sketch.numCoupons;
- Flavor finFlavor = sketch.getFlavor();
- int finOff = sketch.windowOffset;
- double avgC = sumC / trials;
- double avgIconEst = sumIconEst / trials;
- double avgHipEst = sumHipEst / trials;
+ final long finC = sketch.numCoupons;
+ final Flavor finFlavor = sketch.getFlavor();
+ final int finOff = sketch.windowOffset;
+ final double avgC = sumC / trials;
+ final double avgIconEst = sumIconEst / trials;
+ final double avgHipEst = sumHipEst / trials;
printf(dfmt, lgK, trials, n, finC, finFlavor, finOff, avgC, avgIconEst, avgHipEst);
}
- private void printf(String format, Object ... args) {
+ private void printf(final String format, final Object ... args) {
if (printStream != null) { printStream.printf(format, args); }
if (printWriter != null) { printWriter.printf(format, args); }
}
private void assembleStrings() {
- String[][] assy = {
+ final String[][] assy = {
{"lgK", "%3s", "%3d"},
{"Trials", "%7s", "%7d"},
{"n", "%8s", "%8d"},
@@ -134,13 +139,13 @@ public class StreamingValidation {
{"AvgICON", "%12s", "%12.3f"},
{"AvgHIP", "%12s", "%12.3f"}
};
- int cols = assy.length;
+ final int cols = assy.length;
hStrArr = new String[cols];
- StringBuilder headerFmt = new StringBuilder();
- StringBuilder dataFmt = new StringBuilder();
+ final StringBuilder headerFmt = new StringBuilder();
+ final StringBuilder dataFmt = new StringBuilder();
headerFmt.append("\nStreaming Validation\n");
for (int i = 0; i < cols; i++) {
- hStrArr[i] =assy[i][0];
+ hStrArr[i] = assy[i][0];
headerFmt.append(assy[i][1]);
headerFmt.append((i < (cols - 1)) ? "\t" : "\n");
dataFmt.append(assy[i][2]);
diff --git a/src/test/java/org/apache/datasketches/cpc/TestUtil.java b/src/main/java/org/apache/datasketches/cpc/TestUtil.java
similarity index 90%
rename from src/test/java/org/apache/datasketches/cpc/TestUtil.java
rename to src/main/java/org/apache/datasketches/cpc/TestUtil.java
index 70607ec..0a96db7 100644
--- a/src/test/java/org/apache/datasketches/cpc/TestUtil.java
+++ b/src/main/java/org/apache/datasketches/cpc/TestUtil.java
@@ -19,10 +19,10 @@
package org.apache.datasketches.cpc;
-import static org.apache.datasketches.cpc.RuntimeAsserts.rtAssert;
-import static org.apache.datasketches.cpc.RuntimeAsserts.rtAssertEquals;
import static java.lang.Math.pow;
import static java.lang.Math.round;
+import static org.apache.datasketches.cpc.RuntimeAsserts.rtAssert;
+import static org.apache.datasketches.cpc.RuntimeAsserts.rtAssertEquals;
/**
* @author Lee Rhodes
@@ -72,21 +72,21 @@ public class TestUtil {
return true;
}
- static int calculateFirstInterestingColumn(CpcSketch sketch) {
- int offset = sketch.windowOffset;
+ static int calculateFirstInterestingColumn(final CpcSketch sketch) {
+ final int offset = sketch.windowOffset;
if (offset == 0) {
return 0;
}
- PairTable table = sketch.pairTable;
+ final PairTable table = sketch.pairTable;
assert (table != null);
- int[] slots = table.getSlotsArr();
- int numSlots = 1 << table.getLgSizeInts();
+ final int[] slots = table.getSlotsArr();
+ final int numSlots = 1 << table.getLgSizeInts();
int i;
int result = offset;
for (i = 0; i < numSlots; i++) {
- int rowCol = slots[i];
+ final int rowCol = slots[i];
if (rowCol != -1) {
- int col = rowCol & 63;
+ final int col = rowCol & 63;
if (col < result) { result = col; }
}
}
diff --git a/src/test/java/org/apache/datasketches/cpc/CpcCBinariesTest.java b/src/test/java/org/apache/datasketches/cpc/CpcCBinariesTest.java
index d578609..5c548f9 100644
--- a/src/test/java/org/apache/datasketches/cpc/CpcCBinariesTest.java
+++ b/src/test/java/org/apache/datasketches/cpc/CpcCBinariesTest.java
@@ -41,24 +41,24 @@ public class CpcCBinariesTest {
@Test
public void checkEmptyBin() {
- String fileName = "cpc-empty.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-empty.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory wmem = mh.get();
+ final Memory wmem = mh.get();
println(PreambleUtil.toString(wmem, true));
- CpcSketch sk = CpcSketch.heapify(wmem);
+ final CpcSketch sk = CpcSketch.heapify(wmem);
assertEquals(sk.getFlavor(), Flavor.EMPTY);
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkSparseBin() {
- String fileName = "cpc-sparse.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-sparse.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
+ final Memory mem = mh.get();
println("CPP GENERATED SKETCH FROM BINARY FILE LgK=11, U0 to U99");
println("PreambleUtil.toString(mem, true)" + LS);
println(PreambleUtil.toString(mem, true));
@@ -66,25 +66,25 @@ public class CpcCBinariesTest {
println(LS + LS + "################");
println("CpcSketch sk = CpcSketch.heapify(mem);");
println("sk.toString(true)" + LS);
- CpcSketch sk = CpcSketch.heapify(mem);
+ final CpcSketch sk = CpcSketch.heapify(mem);
println(sk.toString(true));
assertEquals(sk.getFlavor(), Flavor.SPARSE);
- double est1 = sk.getEstimate();
+ final double est1 = sk.getEstimate();
assertEquals(est1, 100, 100 * .02);
for (int i = 0; i < 100; i++) { sk.update(i); }
- double est2 = sk.getEstimate();
+ final double est2 = sk.getEstimate();
assertEquals(est2, est1, 0); //assert no change
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkHybridBin() {
- String fileName = "cpc-hybrid.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-hybrid.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
+ final Memory mem = mh.get();
println("CPP GENERATED SKETCH FROM BINARY FILE LgK=11, U0 to U199");
println("PreambleUtil.toString(mem, true)" + LS);
println(PreambleUtil.toString(mem, true));
@@ -92,25 +92,25 @@ public class CpcCBinariesTest {
println(LS + LS + "################");
println("CpcSketch sk = CpcSketch.heapify(mem);");
println("sk.toString(true)" + LS);
- CpcSketch sk = CpcSketch.heapify(mem);
+ final CpcSketch sk = CpcSketch.heapify(mem);
println(sk.toString(true));
assertEquals(sk.getFlavor(), Flavor.HYBRID);
- double est1 = sk.getEstimate();
+ final double est1 = sk.getEstimate();
assertEquals(est1, 200, 200 * .02);
for (long i = 0; i < 200; i++) { sk.update(i); }
- double est2 = sk.getEstimate();
+ final double est2 = sk.getEstimate();
assertEquals(est2, est1, 0); //assert no change
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkPinnedBin() {
- String fileName = "cpc-pinned.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-pinned.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
+ final Memory mem = mh.get();
println("CPP GENERATED SKETCH FROM BINARY FILE LgK=11, U0 to U1999");
println("PreambleUtil.toString(mem, true)" + LS);
println(PreambleUtil.toString(mem, true));
@@ -118,25 +118,25 @@ public class CpcCBinariesTest {
println(LS + LS + "################");
println("CpcSketch sk = CpcSketch.heapify(mem);");
println("sk.toString(true)" + LS);
- CpcSketch sk = CpcSketch.heapify(mem);
+ final CpcSketch sk = CpcSketch.heapify(mem);
println(sk.toString(true));
assertEquals(sk.getFlavor(), Flavor.PINNED);
- double est1 = sk.getEstimate();
+ final double est1 = sk.getEstimate();
assertEquals(est1, 2000, 2000 * .02);
for (long i = 0; i < 2000; i++) { sk.update(i); }
- double est2 = sk.getEstimate();
+ final double est2 = sk.getEstimate();
assertEquals(est2, est1, 0); //assert no change
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkSlidingBin() {
- String fileName = "cpc-sliding.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-sliding.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
+ final Memory mem = mh.get();
println("CPP GENERATED SKETCH FROM BINARY FILE LgK=11, U0 to U19999");
println("PreambleUtil.toString(mem, true)" + LS);
println(PreambleUtil.toString(mem, true));
@@ -144,15 +144,15 @@ public class CpcCBinariesTest {
println(LS + LS + "################");
println("CpcSketch sk = CpcSketch.heapify(mem);");
println("sk.toString(true)" + LS);
- CpcSketch sk = CpcSketch.heapify(mem);
+ final CpcSketch sk = CpcSketch.heapify(mem);
println(sk.toString(true));
assertEquals(sk.getFlavor(), Flavor.SLIDING);
- double est1 = sk.getEstimate();
+ final double est1 = sk.getEstimate();
assertEquals(est1, 20000, 20000 * .02);
for (long i = 0; i < 20000; i++) { sk.update(i); }
- double est2 = sk.getEstimate();
+ final double est2 = sk.getEstimate();
assertEquals(est2, est1, 0);
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@@ -161,118 +161,118 @@ public class CpcCBinariesTest {
@Test
public void checkEmptyImages() {
- String fileName = "cpc-empty.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-empty.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
- int cap = (int) mem.getCapacity();
- byte[] memByteArr = new byte[cap];
+ final Memory mem = mh.get();
+ final int cap = (int) mem.getCapacity();
+ final byte[] memByteArr = new byte[cap];
mem.getByteArray(0, memByteArr, 0, cap);
- CpcSketch sk = new CpcSketch(11);
- byte[] mem2ByteArr = sk.toByteArray();
- Memory mem2 = Memory.wrap(mem2ByteArr);
+ final CpcSketch sk = new CpcSketch(11);
+ final byte[] mem2ByteArr = sk.toByteArray();
+ final Memory mem2 = Memory.wrap(mem2ByteArr);
assertEquals(mem.getCapacity(), mem2.getCapacity());
assertEquals(memByteArr, mem2ByteArr);
- }catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkSparseImages() {
- String fileName = "cpc-sparse.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-sparse.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
- int cap = (int) mem.getCapacity();
- byte[] memByteArr = new byte[cap];
+ final Memory mem = mh.get();
+ final int cap = (int) mem.getCapacity();
+ final byte[] memByteArr = new byte[cap];
mem.getByteArray(0, memByteArr, 0, cap);
- CpcSketch sk = new CpcSketch(11);
+ final CpcSketch sk = new CpcSketch(11);
for (int i = 0; i < 100; i++) { sk.update(i); }
- byte[] mem2ByteArr = sk.toByteArray();
- Memory mem2 = Memory.wrap(mem2ByteArr);
+ final byte[] mem2ByteArr = sk.toByteArray();
+ final Memory mem2 = Memory.wrap(mem2ByteArr);
assertEquals(mem.getCapacity(), mem2.getCapacity());
assertEquals(memByteArr, mem2ByteArr);
- }catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkHybridImages() {
- String fileName = "cpc-hybrid.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-hybrid.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
- int cap = (int) mem.getCapacity();
- byte[] memByteArr = new byte[cap];
+ final Memory mem = mh.get();
+ final int cap = (int) mem.getCapacity();
+ final byte[] memByteArr = new byte[cap];
mem.getByteArray(0, memByteArr, 0, cap);
- CpcSketch sk = new CpcSketch(11);
+ final CpcSketch sk = new CpcSketch(11);
for (int i = 0; i < 200; i++) { sk.update(i); }
- byte[] mem2ByteArr = sk.toByteArray();
- Memory mem2 = Memory.wrap(mem2ByteArr);
+ final byte[] mem2ByteArr = sk.toByteArray();
+ final Memory mem2 = Memory.wrap(mem2ByteArr);
assertEquals(mem.getCapacity(), mem2.getCapacity());
assertEquals(memByteArr, mem2ByteArr);
- }catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkPinnedImages() {
- String fileName = "cpc-pinned.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-pinned.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
- int cap = (int) mem.getCapacity();
- byte[] cppMemByteArr = new byte[cap];
+ final Memory mem = mh.get();
+ final int cap = (int) mem.getCapacity();
+ final byte[] cppMemByteArr = new byte[cap];
mem.getByteArray(0, cppMemByteArr, 0, cap);
- CpcSketch sk = new CpcSketch(11);
+ final CpcSketch sk = new CpcSketch(11);
for (int i = 0; i < 2000; i++) { sk.update(i); }
- byte[] javaMemByteArr = sk.toByteArray();
- Memory mem2 = Memory.wrap(javaMemByteArr);
+ final byte[] javaMemByteArr = sk.toByteArray();
+ final Memory mem2 = Memory.wrap(javaMemByteArr);
assertEquals(mem.getCapacity(), mem2.getCapacity());
assertEquals(cppMemByteArr, javaMemByteArr);
- }catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test
public void checkSlidingImages() {
- String fileName = "cpc-sliding.bin";
- File file = getResourceFile(fileName);
+ final String fileName = "cpc-sliding.bin";
+ final File file = getResourceFile(fileName);
try (MapHandle mh = Memory.map(file)) {
- Memory mem = mh.get();
- int cap = (int) mem.getCapacity();
- byte[] memByteArr = new byte[cap];
+ final Memory mem = mh.get();
+ final int cap = (int) mem.getCapacity();
+ final byte[] memByteArr = new byte[cap];
mem.getByteArray(0, memByteArr, 0, cap);
- CpcSketch sk = new CpcSketch(11);
+ final CpcSketch sk = new CpcSketch(11);
for (int i = 0; i < 20000; i++) { sk.update(i); }
- byte[] mem2ByteArr = sk.toByteArray();
- Memory mem2 = Memory.wrap(mem2ByteArr);
+ final byte[] mem2ByteArr = sk.toByteArray();
+ final Memory mem2 = Memory.wrap(mem2ByteArr);
assertEquals(mem.getCapacity(), mem2.getCapacity());
assertEquals(memByteArr, mem2ByteArr);
- }catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@Test //Internal consistency check
public void genSparseSketch() {
- CpcSketch sk = new CpcSketch(11);
+ final CpcSketch sk = new CpcSketch(11);
for (int i = 0; i < 100; i++) { sk.update(i); }
println("JAVA GENERATED SKETCH LgK=11, U0 to U99");
println("sketch.toString(true);" + LS);
println(sk.toString(true));
println(LS + LS + "################");
- byte[] byteArray = sk.toByteArray();
+ final byte[] byteArray = sk.toByteArray();
println("sketch.toByteArray();");
println("PreambleUtil.toString(byteArray, true);" + LS);
println(PreambleUtil.toString(byteArray, true));
@@ -280,7 +280,7 @@ public class CpcCBinariesTest {
println(LS + LS + "################");
println("CpcSketch sk2 = CpcSketch.heapify(byteArray);");
println("sk2.toString(true);" + LS);
- CpcSketch sk2 = CpcSketch.heapify(byteArray);
+ final CpcSketch sk2 = CpcSketch.heapify(byteArray);
println(sk2.toString(true));
}
@@ -293,14 +293,14 @@ public class CpcCBinariesTest {
* @param format the string to print
* @param args the arguments
*/
- static void printf(String format, Object... args) {
+ static void printf(final String format, final Object... args) {
//ps.printf(format, args);
}
/**
* @param s value to print
*/
- static void println(String s) {
+ static void println(final String s) {
//ps.println(s); //disable here
}
diff --git a/src/test/java/org/apache/datasketches/cpc/CpcCompressionTest.java b/src/test/java/org/apache/datasketches/cpc/CpcCompressionTest.java
index d2b66f8..1ddf1d6 100644
--- a/src/test/java/org/apache/datasketches/cpc/CpcCompressionTest.java
+++ b/src/test/java/org/apache/datasketches/cpc/CpcCompressionTest.java
@@ -48,7 +48,7 @@ public class CpcCompressionTest {
@Test
public void checkWriteReadUnary() {
- int[] compressedWords = new int[256];
+ final int[] compressedWords = new int[256];
final long[] ptrArr = new long[3];
int nextWordIndex = 0; //must be int
@@ -72,7 +72,7 @@ public class CpcCompressionTest {
}
// Pad the bitstream so that the decompressor's 12-bit peek can't overrun its input.
- long padding = 7;
+ final long padding = 7;
bufBits += padding;
//MAYBE_FLUSH_BITBUF(compressedWords, nextWordIndex);
if (bufBits >= 32) {
@@ -85,7 +85,7 @@ public class CpcCompressionTest {
assert (bufBits < 32);
compressedWords[nextWordIndex++] = (int) bitBuf;
}
- int numWordsUsed = nextWordIndex;
+ final int numWordsUsed = nextWordIndex;
println("Words used: " + numWordsUsed);
nextWordIndex = 0; //must be int
bitBuf = 0; //must be long
@@ -114,13 +114,13 @@ public class CpcCompressionTest {
@Test
public void checkWriteReadBytes() {
- int[] compressedWords = new int[128];
- byte[] byteArray = new byte[256];
- byte[] byteArray2 = new byte[256]; //output
+ final int[] compressedWords = new int[128];
+ final byte[] byteArray = new byte[256];
+ final byte[] byteArray2 = new byte[256]; //output
for (int i = 0; i < 256; i++) { byteArray[i] = (byte) i; }
for (int j = 0; j < 22; j++) {
- long numWordsWritten = lowLevelCompressBytes(
+ final long numWordsWritten = lowLevelCompressBytes(
byteArray, 256, encodingTablesForHighEntropyByte[j], compressedWords);
lowLevelUncompressBytes(byteArray2, 256, decodingTablesForHighEntropyByte[j],
@@ -133,13 +133,13 @@ public class CpcCompressionTest {
@Test
public void checkWriteReadBytes65() {
- int size = 65;
- int[] compressedWords = new int[128];
- byte[] byteArray = new byte[size];
- byte[] byteArray2 = new byte[size]; //output
+ final int size = 65;
+ final int[] compressedWords = new int[128];
+ final byte[] byteArray = new byte[size];
+ final byte[] byteArray2 = new byte[size]; //output
for (int i = 0; i < size; i++) { byteArray[i] = (byte) i; }
- long numWordsWritten = lowLevelCompressBytes(
+ final long numWordsWritten = lowLevelCompressBytes(
byteArray, size, lengthLimitedUnaryEncodingTable65, compressedWords);
lowLevelUncompressBytes(byteArray2, size, lengthLimitedUnaryDecodingTable65,
@@ -152,15 +152,15 @@ public class CpcCompressionTest {
@Test
public void checkWriteReadPairs() {
- Random rgen = new Random(1);
- int lgK = 14;
- int N = 3000;
+ final Random rgen = new Random(1);
+ final int lgK = 14;
+ final int N = 3000;
final int MAX_WORDS = 4000;
- int[] pairArray = new int[N];
- int[] pairArray2 = new int[N];
+ final int[] pairArray = new int[N];
+ final int[] pairArray2 = new int[N];
int i;
for (i = 0; i < N; i++) {
- int rand = rgen.nextInt(1 << (lgK + 6));
+ final int rand = rgen.nextInt(1 << (lgK + 6));
pairArray[i] = rand;
}
Arrays.sort(pairArray); //must be unsigned sort! So keep lgK < 26
@@ -172,14 +172,14 @@ public class CpcCompressionTest {
pairArray[nxt++] = pairArray[i];
}
}
- int numPairs = nxt;
+ final int numPairs = nxt;
println("numCsv = " + numPairs);
- int[] compressedWords = new int[MAX_WORDS];
+ final int[] compressedWords = new int[MAX_WORDS];
int bb; // numBaseBits
for (bb = 0; bb <= 11; bb++) {
- Long numWordsWritten =
+ final Long numWordsWritten =
lowLevelCompressPairs(pairArray, numPairs, bb, compressedWords);
println("numWordsWritten = " + numWordsWritten + ", bb = " + bb);
@@ -199,7 +199,7 @@ public class CpcCompressionTest {
/**
* @param s value to print
*/
- static void println(String s) {
+ static void println(final String s) {
//System.out.println(s); //disable here
}
diff --git a/src/test/java/org/apache/datasketches/cpc/CpcSketchTest.java b/src/test/java/org/apache/datasketches/cpc/CpcSketchTest.java
index f741e65..4f20ada 100644
--- a/src/test/java/org/apache/datasketches/cpc/CpcSketchTest.java
+++ b/src/test/java/org/apache/datasketches/cpc/CpcSketchTest.java
@@ -27,11 +27,10 @@ import static org.testng.Assert.fail;
import java.io.PrintStream;
-import org.testng.annotations.Test;
-
-import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.Family;
import org.apache.datasketches.SketchesArgumentException;
+import org.apache.datasketches.memory.Memory;
+import org.testng.annotations.Test;
/**
* @author Lee Rhodes
@@ -42,7 +41,7 @@ public class CpcSketchTest {
@Test
public void checkUpdatesEstimate() {
- CpcSketch sk = new CpcSketch(10, 0);
+ final CpcSketch sk = new CpcSketch(10, 0);
println(sk.toString(true));
assertEquals(sk.getFormat(), Format.EMPTY_HIP);
sk.update(1L);
@@ -52,9 +51,9 @@ public class CpcSketchTest {
sk.update(new char[] { 5 });
sk.update(new int[] { 6 });
sk.update(new long[] { 7 });
- double est = sk.getEstimate();
- double lb = sk.getLowerBound(2);
- double ub = sk.getUpperBound(2);
+ final double est = sk.getEstimate();
+ final double lb = sk.getLowerBound(2);
+ final double ub = sk.getUpperBound(2);
assertTrue(lb >= 0);
assertTrue(lb <= est);
assertTrue(est <= ub);
@@ -66,21 +65,21 @@ public class CpcSketchTest {
@Test
public void checkEstimatesWithMerge() {
- int lgK = 4;
- CpcSketch sk1 = new CpcSketch(lgK);
- CpcSketch sk2 = new CpcSketch(lgK);
- int n = 1 << lgK;
+ final int lgK = 4;
+ final CpcSketch sk1 = new CpcSketch(lgK);
+ final CpcSketch sk2 = new CpcSketch(lgK);
+ final int n = 1 << lgK;
for (int i = 0; i < n; i++ ) {
sk1.update(i);
sk2.update(i + n);
}
- CpcUnion union = new CpcUnion(lgK);
+ final CpcUnion union = new CpcUnion(lgK);
union.update(sk1);
union.update(sk2);
- CpcSketch result = union.getResult();
- double est = result.getEstimate();
- double lb = result.getLowerBound(2);
- double ub = result.getUpperBound(2);
+ final CpcSketch result = union.getResult();
+ final double est = result.getEstimate();
+ final double lb = result.getLowerBound(2);
+ final double ub = result.getUpperBound(2);
assertTrue(lb >= 0);
assertTrue(lb <= est);
assertTrue(est <= ub);
@@ -90,8 +89,8 @@ public class CpcSketchTest {
@Test
public void checkCornerCaseUpdates() {
- int lgK = 4;
- CpcSketch sk = new CpcSketch(lgK);
+ final int lgK = 4;
+ final CpcSketch sk = new CpcSketch(lgK);
sk.update(0.0);
sk.update(-0.0);
int est = (int) Math.round(sk.getEstimate());
@@ -138,25 +137,25 @@ public class CpcSketchTest {
@Test
public void checkCornerHashUpdates() {
- CpcSketch sk = new CpcSketch(26);
- long hash1 = 0;
- long hash0 = -1L;
+ final CpcSketch sk = new CpcSketch(26);
+ final long hash1 = 0;
+ final long hash0 = -1L;
sk.hashUpdate(hash0, hash1);
- PairTable table = sk.pairTable;
+ final PairTable table = sk.pairTable;
println(table.toString(true));
}
@SuppressWarnings("unused")
@Test
public void checkCopyWithWindow() {
- int lgK = 4;
- CpcSketch sk = new CpcSketch(lgK);
+ final int lgK = 4;
+ final CpcSketch sk = new CpcSketch(lgK);
CpcSketch sk2 = sk.copy();
for (int i = 0; i < (1 << lgK); i++) { //pinned
sk.update(i);
}
sk2 = sk.copy();
- long[] bitMatrix = CpcUtil.bitMatrixOfSketch(sk);
+ final long[] bitMatrix = CpcUtil.bitMatrixOfSketch(sk);
CpcSketch.refreshKXP(sk, bitMatrix);
}
@@ -172,7 +171,7 @@ public class CpcSketchTest {
try {
sk = new CpcSketch(3);
fail();
- } catch (SketchesArgumentException e) {}
+ } catch (final SketchesArgumentException e) { }
}
@Test
diff --git a/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTesting.java b/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java
similarity index 97%
rename from src/test/java/org/apache/datasketches/cpc/LzTzSpeedTesting.java
rename to src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java
index f2e61aa..b134eea 100644
--- a/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTesting.java
+++ b/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java
@@ -29,12 +29,13 @@ import java.util.Random;
* intrinsic CPU instructions instead of the documented code. The java built=in functions are much
* faster than even choosing most probable bytes algorithms that were derived from C.
*
- * <p>These tests are for experimental testing only and are not enabled for normal unit testing.
+ * <p>These tests are for experimental characterization testing only and are not enabled for
+ * normal unit testing.
*
* @author Lee Rhodes
*/
@SuppressWarnings("javadoc")
-public class LzTzSpeedTesting {
+public class LzTzSpeedTest {
static final byte[] byteTrailingZerosTable = new byte[256];
static final byte[] byteLeadingZerosTable = new byte[256];
diff --git a/src/test/java/org/apache/datasketches/cpc/TestAllTest.java b/src/test/java/org/apache/datasketches/cpc/TestAllTest.java
index 006cfd5..d09db5b 100644
--- a/src/test/java/org/apache/datasketches/cpc/TestAllTest.java
+++ b/src/test/java/org/apache/datasketches/cpc/TestAllTest.java
@@ -31,17 +31,18 @@ import org.testng.annotations.Test;
*/
@SuppressWarnings("javadoc")
public class TestAllTest {
+ // Enable these as desired for all tests.
+ private PrintStream ps = null; //System.out; //prints to console
+ private PrintWriter pw = null; //prints to file (optional)
//STREAMING
- @Test
+ @Test //scope = Test
public void streamingCheck() {
int lgMinK = 10;
int lgMaxK = 10;
int trials = 10;
int ppoN = 1;
- PrintStream ps = null;//System.out;
- PrintWriter pw = null;
StreamingValidation sVal = new StreamingValidation(
lgMinK, lgMaxK, trials, ppoN, ps, pw);
@@ -50,7 +51,7 @@ public class TestAllTest {
//COMPRESSION
- @Test
+ @Test //scope = Test
public void compressionCharacterizationCheck() {
int lgMinK = 10;
int lgMaxK = 10;
@@ -59,8 +60,6 @@ public class TestAllTest {
int lgMulK = 7;
int uPPO = 1;
int incLgK = 1;
- PrintStream ps = null; //System.out;
- PrintWriter pw = null;
CompressionCharacterization cc = new CompressionCharacterization(
lgMinK, lgMaxK, lgMinT, lgMaxT, lgMulK, uPPO, incLgK, ps, pw);
@@ -69,7 +68,6 @@ public class TestAllTest {
//@Test //used for troubleshooting a specific rowCol problems
public void singleRowColCheck() {
- PrintStream ps = System.out;
int lgK = 20;
CpcSketch srcSketch = new CpcSketch(lgK);
int rowCol = 54746379;
@@ -84,28 +82,24 @@ public class TestAllTest {
//MERGING
- //@Test //long test. use for characterization
+ //@Test //longer test. use for characterization
public void mergingValidationCheck() {
int lgMinK = 10;
int lgMaxK = 10; //inclusive
int lgMulK = 5; //5
int uPPO = 1; //16
int incLgK = 1;
- PrintStream ps = null;//System.out;
- PrintWriter pw = null;
MergingValidation mv = new MergingValidation(
lgMinK, lgMaxK, lgMulK, uPPO, incLgK, ps, pw);
mv.start();
}
- @Test
+ @Test //scope = Test
public void quickMergingValidationCheck() {
int lgMinK = 10;
int lgMaxK = 10;
int incLgK = 1;
- PrintStream ps = null;//System.out;
- PrintWriter pw = null;
QuickMergingValidation qmv = new QuickMergingValidation(
lgMinK, lgMaxK, incLgK, ps, pw);
diff --git a/src/test/java/org/apache/datasketches/frequencies/StressTestHashMap.java b/src/test/java/org/apache/datasketches/frequencies/HashMapStressTest.java
similarity index 79%
rename from src/test/java/org/apache/datasketches/frequencies/StressTestHashMap.java
rename to src/test/java/org/apache/datasketches/frequencies/HashMapStressTest.java
index 947af9b..9d1da66 100644
--- a/src/test/java/org/apache/datasketches/frequencies/StressTestHashMap.java
+++ b/src/test/java/org/apache/datasketches/frequencies/HashMapStressTest.java
@@ -20,15 +20,15 @@
package org.apache.datasketches.frequencies;
import org.apache.datasketches.hash.MurmurHash3;
+//import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
-public class StressTestHashMap {
+public class HashMapStressTest {
- public static void main(String[] args) {
- stress();
- }
-
- private static void stress() {
+ //@Test
+ public static void stress() {
+ println("ReversePurgeLongHashMap Stress Test");
+ printf("%12s%15s%n", "Capacity", "TimePerAdjust");
for (int capacity = 2 << 5; capacity < (2 << 24); capacity *= 2) {
int n = 10000000;
@@ -42,11 +42,12 @@ public class StressTestHashMap {
ReversePurgeLongHashMap hashmap = new ReversePurgeLongHashMap(capacity);
long timePerAdjust = timeOneHashMap(hashmap, keys, values, (int) (.75 * capacity));
- System.out.format("%s\t%d\t%d%n", hashmap.getClass().getSimpleName(), capacity, timePerAdjust);
+ printf("%12d%15d%n", capacity, timePerAdjust);
}
}
- private static long timeOneHashMap(ReversePurgeLongHashMap hashMap, long[] keys, long[] values, int sizeToShift) {
+ private static long timeOneHashMap(ReversePurgeLongHashMap hashMap, long[] keys, long[] values,
+ int sizeToShift) {
final long startTime = System.nanoTime();
int n = keys.length;
assert (n == values.length);
@@ -65,4 +66,9 @@ public class StressTestHashMap {
long[] keyArr = { key };
return MurmurHash3.hash(keyArr, 0)[0];
}
-}
+
+ private static void println(Object obj) { System.out.println(obj.toString()); }
+
+ private static void printf(String fmt, Object ... args) { System.out.printf(fmt, args); }
+
+}
\ No newline at end of file
diff --git a/src/test/java/org/apache/datasketches/theta/BackwardConversions.java b/src/test/java/org/apache/datasketches/theta/BackwardConversions.java
index fee5c30..d0f9081 100644
--- a/src/test/java/org/apache/datasketches/theta/BackwardConversions.java
+++ b/src/test/java/org/apache/datasketches/theta/BackwardConversions.java
@@ -19,10 +19,10 @@
package org.apache.datasketches.theta;
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMemory;
import org.apache.datasketches.SketchesArgumentException;
import org.apache.datasketches.Util;
+import org.apache.datasketches.memory.Memory;
+import org.apache.datasketches.memory.WritableMemory;
/**
* This class converts current compact sketches into prior SerVer 1 and SerVer 2 format for testing.
@@ -77,16 +77,16 @@ public class BackwardConversions {
* @param skV3 a SerVer3, ordered CompactSketch
* @return a SerVer1 SetSketch as Memory object.
*/
- public static Memory convertSerVer3toSerVer1(CompactSketch skV3) {
+ public static Memory convertSerVer3toSerVer1(final CompactSketch skV3) {
//Check input sketch
- boolean validIn = skV3.isCompact() && skV3.isOrdered() && !skV3.hasMemory();
+ final boolean validIn = skV3.isCompact() && skV3.isOrdered() && !skV3.hasMemory();
if (!validIn) {
throw new SketchesArgumentException("Invalid input sketch.");
}
//Build V1 SetSketch in memory
- int curCount = skV3.getRetainedEntries(true);
- WritableMemory wmem = WritableMemory.allocate((3 + curCount) << 3);
+ final int curCount = skV3.getRetainedEntries(true);
+ final WritableMemory wmem = WritableMemory.allocate((3 + curCount) << 3);
//Pre0
wmem.putByte(0, (byte) 3); //preLongs
wmem.putByte(1, (byte) 1); //SerVer
@@ -181,8 +181,8 @@ public class BackwardConversions {
* @param seed used for checking the seed hash (if one exists).
* @return a SerVer2 SetSketch as Memory object.
*/
- public static Memory convertSerVer3toSerVer2(CompactSketch skV3, long seed) {
- short seedHash = Util.computeSeedHash(seed);
+ public static Memory convertSerVer3toSerVer2(final CompactSketch skV3, final long seed) {
+ final short seedHash = Util.computeSeedHash(seed);
WritableMemory wmem = null;
if (skV3 instanceof EmptyCompactSketch) {
@@ -190,30 +190,30 @@ public class BackwardConversions {
wmem.putByte(0, (byte) 1); //preLongs
wmem.putByte(1, (byte) 2); //SerVer
wmem.putByte(2, (byte) 3); //SetSketch
- byte flags = (byte) 0xE; //NoRebuild, Empty, ReadOnly, LE
+ final byte flags = (byte) 0xE; //NoRebuild, Empty, ReadOnly, LE
wmem.putByte(5, flags);
wmem.putShort(6, seedHash);
return wmem;
}
if (skV3 instanceof SingleItemSketch) {
- SingleItemSketch sis = (SingleItemSketch) skV3;
+ final SingleItemSketch sis = (SingleItemSketch) skV3;
wmem = WritableMemory.allocate(24);
wmem.putByte(0, (byte) 2); //preLongs
wmem.putByte(1, (byte) 2); //SerVer
wmem.putByte(2, (byte) 3); //SetSketch
- byte flags = (byte) 0xA; //NoRebuild, notEmpty, ReadOnly, LE
+ final byte flags = (byte) 0xA; //NoRebuild, notEmpty, ReadOnly, LE
wmem.putByte(5, flags);
wmem.putShort(6, seedHash);
wmem.putInt(8, 1);
- long[] arr = sis.getCache();
+ final long[] arr = sis.getCache();
wmem.putLong(16, arr[0]);
return wmem;
}
//General CompactSketch
- int preLongs = skV3.getCurrentPreambleLongs(true);
- int entries = skV3.getRetainedEntries();
- boolean unordered = !(skV3.isOrdered());
- byte flags = (byte) (0xA | (unordered ? 16 : 0)); //Unordered, NoRebuild, notEmpty, ReadOnly, LE
+ final int preLongs = skV3.getCurrentPreambleLongs(true);
+ final int entries = skV3.getRetainedEntries();
+ final boolean unordered = !(skV3.isOrdered());
+ final byte flags = (byte) (0xA | (unordered ? 16 : 0)); //Unordered, NoRebuild, notEmpty, ReadOnly, LE
wmem = WritableMemory.allocate((preLongs + entries) << 3);
wmem.putByte(0, (byte) preLongs); //preLongs
wmem.putByte(1, (byte) 2); //SerVer
@@ -225,8 +225,8 @@ public class BackwardConversions {
if (preLongs == 3) {
wmem.putLong(16, skV3.getThetaLong());
}
- long[] arr = skV3.getCache();
- wmem.putLongArray(preLongs*8, arr, 0, entries);
+ final long[] arr = skV3.getCache();
+ wmem.putLongArray(preLongs * 8, arr, 0, entries);
return wmem;
}
}
diff --git a/src/test/java/org/apache/datasketches/tuple/TestUtil.java b/src/test/java/org/apache/datasketches/tuple/TestUtil.java
index 2c33785..9f88393 100644
--- a/src/test/java/org/apache/datasketches/tuple/TestUtil.java
+++ b/src/test/java/org/apache/datasketches/tuple/TestUtil.java
@@ -27,31 +27,31 @@ import java.util.List;
@SuppressWarnings("javadoc")
public class TestUtil {
- public static List<Double> asList(double[] array) {
- List<Double> list = new ArrayList<>(array.length);
+ public static List<Double> asList(final double[] array) {
+ final List<Double> list = new ArrayList<>(array.length);
for (int i = 0; i < array.length; i++) {
list.add(array[i]);
}
return list;
}
- public static List<Float> asList(float[] array) {
- List<Float> list = new ArrayList<>(array.length);
+ public static List<Float> asList(final float[] array) {
+ final List<Float> list = new ArrayList<>(array.length);
for (int i = 0; i < array.length; i++) {
list.add(array[i]);
}
return list;
}
- public static List<Long> asList(long[] array) {
- List<Long> list = new ArrayList<>(array.length);
+ public static List<Long> asList(final long[] array) {
+ final List<Long> list = new ArrayList<>(array.length);
for (int i = 0; i < array.length; i++) {
list.add(array[i]);
}
return list;
}
- public static void writeBytesToFile(byte[] bytes, String fileName) throws IOException {
+ public static void writeBytesToFile(final byte[] bytes, final String fileName) throws IOException {
try (FileOutputStream out = new FileOutputStream(new File(fileName))) {
out.write(bytes);
}
diff --git a/src/test/java/org/apache/datasketches/tuple/aninteger/EngagementTest.java b/src/test/java/org/apache/datasketches/tuple/aninteger/EngagementTest.java
index 7413181..631e688 100644
--- a/src/test/java/org/apache/datasketches/tuple/aninteger/EngagementTest.java
+++ b/src/test/java/org/apache/datasketches/tuple/aninteger/EngagementTest.java
@@ -139,6 +139,6 @@ public class EngagementTest {
* @param args arguments
*/
private static void printf(String fmt, Object ... args) {
- System.out.printf(fmt, args); //Enable/Disable printing here
+ //System.out.printf(fmt, args); //Enable/Disable printing here
}
}
diff --git a/tools/SketchesCheckstyle.xml b/tools/SketchesCheckstyle.xml
index bd5e06b..3373e58 100644
--- a/tools/SketchesCheckstyle.xml
+++ b/tools/SketchesCheckstyle.xml
@@ -26,7 +26,7 @@ under the License.
SketchesCheckstyle.xml
Checkstyle is very configurable. Be sure to read the documentation at
- http://checkstyle.sourceforge.net (or in your downloaded distribution). Note: Does not work with https.
+ http://checkstyle.sourceforge.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
@@ -38,6 +38,10 @@ under the License.
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java"/>
+ <module name="BeforeExecutionExclusionFileFilter">
+ <property name="fileNamePattern" value=".*Test\.java$"/>
+ </module>
+
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org