From ed9bb4958011afe92f0c01a3f514e73675ef2e0d Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Tue, 14 Jul 2015 09:31:27 +0200 Subject: [PATCH 1/6] Ignore Eclipse files. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cf49ca2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.classpath +.project +.settings/ +target/ \ No newline at end of file From 475d6e02fd3608d7ed46cc534a2429fc64fa95c5 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Tue, 14 Jul 2015 10:05:03 +0200 Subject: [PATCH 2/6] Removed reflective access to fields (package private is enough, explicit reference is simpler and straightforward. Converted from fastutil to HPPC. --- pom.xml | 26 +---- src/main/java/net/agkn/hll/HLL.java | 110 ++++++++++-------- .../java/net/agkn/hll/ExplicitHLLTest.java | 9 +- src/test/java/net/agkn/hll/FullHLLTest.java | 11 +- src/test/java/net/agkn/hll/SparseHLLTest.java | 28 ++--- 5 files changed, 90 insertions(+), 94 deletions(-) diff --git a/pom.xml b/pom.xml index eb50710..5599302 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ org.apache.maven.plugins maven-gpg-plugin + 1.6 sign-artifacts @@ -148,30 +149,11 @@ - it.unimi.dsi - fastutil - ${fastutil-version} + com.carrotsearch + hppc + 0.7.1 - - - org.easymock - easymock - ${easymock-version} - test - - - org.powermock - powermock-module-junit4 - ${powermock-version} - test - - - org.powermock - powermock-api-easymock - ${powermock-version} - test - org.testng diff --git a/src/main/java/net/agkn/hll/HLL.java b/src/main/java/net/agkn/hll/HLL.java index cdfd3ad..0cc8f77 100644 --- a/src/main/java/net/agkn/hll/HLL.java +++ b/src/main/java/net/agkn/hll/HLL.java @@ -18,8 +18,11 @@ import java.util.Arrays; -import it.unimi.dsi.fastutil.ints.Int2ByteOpenHashMap; -import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import com.carrotsearch.hppc.IntByteHashMap; +import com.carrotsearch.hppc.LongHashSet; +import com.carrotsearch.hppc.cursors.IntByteCursor; +import com.carrotsearch.hppc.cursors.LongCursor; + import net.agkn.hll.serialization.HLLMetadata; import net.agkn.hll.serialization.IHLLMetadata; import net.agkn.hll.serialization.ISchemaVersion; @@ -79,11 +82,11 @@ public class HLL implements Cloneable { // ************************************************************************ // Storage // storage used when #type is EXPLICIT, null otherwise - private LongOpenHashSet explicitStorage; + LongHashSet explicitStorage; // storage used when #type is SPARSE, null otherwise - private Int2ByteOpenHashMap sparseProbabilisticStorage; + IntByteHashMap sparseProbabilisticStorage; // storage used when #type is FULL, null otherwise - private BitVector probabilisticStorage; + BitVector probabilisticStorage; // current type of this HLL instance, if this changes then so should the // storage used (see above) @@ -347,13 +350,13 @@ public void addRaw(final long rawValue) { if(explicitStorage.size() > explicitThreshold) { if(!sparseOff) { initializeStorage(HLLType.SPARSE); - for(final long value : explicitStorage) { - addRawSparseProbabilistic(value); + for (LongCursor c : explicitStorage) { + addRawSparseProbabilistic(c.value); } } else { initializeStorage(HLLType.FULL); - for(final long value : explicitStorage) { - addRawProbabilistic(value); + for (LongCursor c : explicitStorage) { + addRawProbabilistic(c.value); } } explicitStorage = null; @@ -366,8 +369,9 @@ public void addRaw(final long rawValue) { // promotion, if necessary if(sparseProbabilisticStorage.size() > sparseThreshold) { initializeStorage(HLLType.FULL); - for(final int registerIndex : sparseProbabilisticStorage.keySet()) { - final byte registerValue = sparseProbabilisticStorage.get(registerIndex); + for(IntByteCursor c : sparseProbabilisticStorage) { + final int registerIndex = c.key; + final byte registerValue = c.value; probabilisticStorage.setMaxRegister(registerIndex, registerValue); } sparseProbabilisticStorage = null; @@ -423,6 +427,7 @@ private void addRawSparseProbabilistic(final long rawValue) { // NOTE: no +1 as in paper since 0-based indexing final int j = (int)(rawValue & mBitsMask); + assert sparseProbabilisticStorage.containsKey(j); final byte currentValue = sparseProbabilisticStorage.get(j); if(p_w > currentValue) { sparseProbabilisticStorage.put(j, p_w); @@ -488,10 +493,10 @@ private void initializeStorage(final HLLType type) { // nothing to be done break; case EXPLICIT: - this.explicitStorage = new LongOpenHashSet(); + this.explicitStorage = new LongHashSet(); break; case SPARSE: - this.sparseProbabilisticStorage = new Int2ByteOpenHashMap(); + this.sparseProbabilisticStorage = new IntByteHashMap(); break; case FULL: this.probabilisticStorage = new BitVector(regwidth, m); @@ -541,6 +546,7 @@ public long cardinality() { double sum = 0; int numberOfZeroes = 0/*"V" in the paper*/; for(int j=0; j currentRegisterValue) { - sparseProbabilisticStorage.put(registerIndex, registerValue); - } + for(IntByteCursor c : other.sparseProbabilisticStorage) { + final int registerIndex = c.key; + final byte registerValue = c.value; + final byte currentRegisterValue = sparseProbabilisticStorage.get(registerIndex); + if(registerValue > currentRegisterValue) { + sparseProbabilisticStorage.put(registerIndex, registerValue); + } } // promotion, if necessary if(sparseProbabilisticStorage.size() > sparseThreshold) { initializeStorage(HLLType.FULL); - for(final int registerIndex : sparseProbabilisticStorage.keySet()) { - final byte registerValue = sparseProbabilisticStorage.get(registerIndex); - probabilisticStorage.setMaxRegister(registerIndex, registerValue); + for(IntByteCursor c : sparseProbabilisticStorage) { + final int registerIndex = c.key; + final byte registerValue = c.value; + probabilisticStorage.setMaxRegister(registerIndex, registerValue); } sparseProbabilisticStorage = null; } @@ -887,7 +898,7 @@ public byte[] toBytes(final ISchemaVersion schemaVersion) { final IWordSerializer serializer = schemaVersion.getSerializer(type, Long.SIZE, explicitStorage.size()); - final long[] values = explicitStorage.toLongArray(); + final long[] values = explicitStorage.toArray(); Arrays.sort(values); for(final long value : values) { serializer.writeWord(value); @@ -900,9 +911,10 @@ public byte[] toBytes(final ISchemaVersion schemaVersion) { final IWordSerializer serializer = schemaVersion.getSerializer(type, shortWordLength, sparseProbabilisticStorage.size()); - final int[] indices = sparseProbabilisticStorage.keySet().toIntArray(); + final int[] indices = sparseProbabilisticStorage.keys().toArray(); Arrays.sort(indices); for(final int registerIndex : indices) { + assert sparseProbabilisticStorage.containsKey(registerIndex); final long registerValue = sparseProbabilisticStorage.get(registerIndex); // pack index and value into "short word" final long shortWord = ((registerIndex << regwidth) | registerValue); diff --git a/src/test/java/net/agkn/hll/ExplicitHLLTest.java b/src/test/java/net/agkn/hll/ExplicitHLLTest.java index 80cf526..898fceb 100644 --- a/src/test/java/net/agkn/hll/ExplicitHLLTest.java +++ b/src/test/java/net/agkn/hll/ExplicitHLLTest.java @@ -16,18 +16,19 @@ * limitations under the License. */ -import static org.powermock.reflect.Whitebox.getInternalState; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import java.util.HashSet; import java.util.Random; import net.agkn.hll.serialization.ISchemaVersion; import net.agkn.hll.serialization.SerializationUtil; + import org.testng.annotations.Test; +import com.carrotsearch.hppc.LongHashSet; + /** * Tests {@link HLL} of type {@link HLLType#EXPLICIT}. * @@ -222,8 +223,8 @@ public void promotionTest() { * Asserts that values in both sets are exactly equal. */ private static void assertElementsEqual(final HLL hllA, final HLL hllB) { - final LongOpenHashSet internalSetA = (LongOpenHashSet)getInternalState(hllA, "explicitStorage"); - final LongOpenHashSet internalSetB = (LongOpenHashSet)getInternalState(hllB, "explicitStorage"); + final LongHashSet internalSetA = hllA.explicitStorage; + final LongHashSet internalSetB = hllB.explicitStorage; assertTrue(internalSetA.equals(internalSetB)); } diff --git a/src/test/java/net/agkn/hll/FullHLLTest.java b/src/test/java/net/agkn/hll/FullHLLTest.java index e837929..f8d4cf5 100644 --- a/src/test/java/net/agkn/hll/FullHLLTest.java +++ b/src/test/java/net/agkn/hll/FullHLLTest.java @@ -16,7 +16,6 @@ * limitations under the License. */ -import static org.powermock.reflect.Whitebox.getInternalState; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertFalse; @@ -163,7 +162,7 @@ public void registerValueTest() { { // scoped locally for sanity final int regwidth = 4; final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL); - final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/; + final BitVector bitVector = hll.probabilisticStorage; // lower-bounds of the register hll.addRaw(0x000000000000001L/*'j'=1*/); @@ -210,7 +209,7 @@ public void registerValueTest() { { // scoped locally for sanity final int regwidth = 5; final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL); - final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/; + final BitVector bitVector = hll.probabilisticStorage; // lower-bounds of the register hll.addRaw(0x0000000000000001L/*'j'=1*/); @@ -256,7 +255,7 @@ public void clearTest() { final int m = 1 << log2m; final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, 256/*sparseThreshold, arbitrary, unused*/, HLLType.FULL); - final BitVector bitVector = (BitVector)getInternalState(hll, "probabilisticStorage")/*for testing convenience*/; + final BitVector bitVector = hll.probabilisticStorage; for(int i=0; i Date: Tue, 14 Jul 2015 10:24:00 +0200 Subject: [PATCH 3/6] Corrections to copy-paste mistakes. --- src/main/java/net/agkn/hll/HLL.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/agkn/hll/HLL.java b/src/main/java/net/agkn/hll/HLL.java index 0cc8f77..1ca94fd 100644 --- a/src/main/java/net/agkn/hll/HLL.java +++ b/src/main/java/net/agkn/hll/HLL.java @@ -704,7 +704,7 @@ public void union(final HLL other) { sparseProbabilisticStorage = other.sparseProbabilisticStorage.clone(); } else { initializeStorage(HLLType.FULL); - for(IntByteCursor c : sparseProbabilisticStorage) { + for(IntByteCursor c : other.sparseProbabilisticStorage) { final int registerIndex = c.key; final byte registerValue = c.value; probabilisticStorage.setMaxRegister(registerIndex, registerValue); @@ -746,7 +746,7 @@ public void union(final HLL other) { sparseProbabilisticStorage = other.sparseProbabilisticStorage.clone(); } else { initializeStorage(HLLType.FULL); - for(IntByteCursor c : sparseProbabilisticStorage) { + for(IntByteCursor c : other.sparseProbabilisticStorage) { final int registerIndex = c.key; final byte registerValue = c.value; probabilisticStorage.setMaxRegister(registerIndex, registerValue); From c879ecc020118304e1245600b27c51f431f23104 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Tue, 14 Jul 2015 10:36:23 +0200 Subject: [PATCH 4/6] cutover to regular junit. --- pom.xml | 12 ++++-------- src/test/java/net/agkn/hll/ExplicitHLLTest.java | 6 ++---- src/test/java/net/agkn/hll/FullHLLTest.java | 7 ++----- src/test/java/net/agkn/hll/SparseHLLTest.java | 6 ++---- .../BigEndianAscendingWordDeserializerTest.java | 7 ++----- .../BigEndianAscendingWordSerializerTest.java | 7 ++----- .../hll/serialization/HLLSerializationTest.java | 14 +++++++------- src/test/java/net/agkn/hll/util/BitVectorTest.java | 11 ++++------- src/test/java/net/agkn/hll/util/HLLUtilTest.java | 4 ++-- 9 files changed, 27 insertions(+), 47 deletions(-) diff --git a/pom.xml b/pom.xml index 5599302..1378824 100644 --- a/pom.xml +++ b/pom.xml @@ -154,13 +154,11 @@ 0.7.1 - - org.testng - testng - ${testng-version} - test - jdk15 + junit + junit + 4.10 + test @@ -172,7 +170,5 @@ 3.0 1.4.8 - 5.7 - 6.5.11 \ No newline at end of file diff --git a/src/test/java/net/agkn/hll/ExplicitHLLTest.java b/src/test/java/net/agkn/hll/ExplicitHLLTest.java index 898fceb..b3f6b53 100644 --- a/src/test/java/net/agkn/hll/ExplicitHLLTest.java +++ b/src/test/java/net/agkn/hll/ExplicitHLLTest.java @@ -16,8 +16,8 @@ * limitations under the License. */ -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.Assert.*; +import org.junit.Test; import java.util.HashSet; import java.util.Random; @@ -25,8 +25,6 @@ import net.agkn.hll.serialization.ISchemaVersion; import net.agkn.hll.serialization.SerializationUtil; -import org.testng.annotations.Test; - import com.carrotsearch.hppc.LongHashSet; /** diff --git a/src/test/java/net/agkn/hll/FullHLLTest.java b/src/test/java/net/agkn/hll/FullHLLTest.java index f8d4cf5..04e2423 100644 --- a/src/test/java/net/agkn/hll/FullHLLTest.java +++ b/src/test/java/net/agkn/hll/FullHLLTest.java @@ -16,9 +16,8 @@ * limitations under the License. */ -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; +import static org.junit.Assert.*; +import org.junit.Test; import net.agkn.hll.serialization.ISchemaVersion; import net.agkn.hll.serialization.SerializationUtil; @@ -26,8 +25,6 @@ import net.agkn.hll.util.HLLUtil; import net.agkn.hll.util.LongIterator; -import org.testng.annotations.Test; - /** * Tests {@link HLL} of type {@link HLLType#FULL}. * diff --git a/src/test/java/net/agkn/hll/SparseHLLTest.java b/src/test/java/net/agkn/hll/SparseHLLTest.java index 7a64ff8..68b0b69 100644 --- a/src/test/java/net/agkn/hll/SparseHLLTest.java +++ b/src/test/java/net/agkn/hll/SparseHLLTest.java @@ -16,8 +16,8 @@ * limitations under the License. */ -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.Assert.*; +import org.junit.Test; import java.util.Random; @@ -25,8 +25,6 @@ import net.agkn.hll.serialization.SerializationUtil; import net.agkn.hll.util.HLLUtil; -import org.testng.annotations.Test; - import com.carrotsearch.hppc.IntByteHashMap; import com.carrotsearch.hppc.cursors.IntByteCursor; diff --git a/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordDeserializerTest.java b/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordDeserializerTest.java index b2701ae..d7b6781 100644 --- a/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordDeserializerTest.java +++ b/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordDeserializerTest.java @@ -17,12 +17,10 @@ */ -import org.testng.annotations.Test; import java.util.Random; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.junit.Assert.*; +import org.junit.Test; /** * Unit and smoke tests for {@link BigEndianAscendingWordDeserializer}. @@ -33,7 +31,6 @@ public class BigEndianAscendingWordDeserializerTest { /** * Error checking tests for constructor. */ - @SuppressWarnings("unused") @Test public void constructorErrorTest() { // word length too small diff --git a/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordSerializerTest.java b/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordSerializerTest.java index 45c9d0a..3042812 100644 --- a/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordSerializerTest.java +++ b/src/test/java/net/agkn/hll/serialization/BigEndianAscendingWordSerializerTest.java @@ -16,12 +16,10 @@ * limitations under the License. */ -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - import java.util.Arrays; -import org.testng.annotations.Test; +import static org.junit.Assert.*; +import org.junit.Test; /** * Unit tests for {@link BigEndianAscendingWordSerializer}. @@ -32,7 +30,6 @@ public class BigEndianAscendingWordSerializerTest { /** * Error checking tests for constructor. */ - @SuppressWarnings("unused") @Test public void constructorErrorTest() { // word length too small diff --git a/src/test/java/net/agkn/hll/serialization/HLLSerializationTest.java b/src/test/java/net/agkn/hll/serialization/HLLSerializationTest.java index c3d0d94..e49d343 100644 --- a/src/test/java/net/agkn/hll/serialization/HLLSerializationTest.java +++ b/src/test/java/net/agkn/hll/serialization/HLLSerializationTest.java @@ -2,7 +2,9 @@ import net.agkn.hll.HLL; import net.agkn.hll.HLLType; -import org.testng.annotations.Test; + +import static org.junit.Assert.*; +import org.junit.Test; import java.util.ArrayList; import java.util.Collection; @@ -14,7 +16,6 @@ import static net.agkn.hll.HLL.MINIMUM_EXPTHRESH_PARAM; import static net.agkn.hll.HLL.MINIMUM_LOG2M_PARAM; import static net.agkn.hll.HLL.MINIMUM_REGWIDTH_PARAM; -import static org.testng.Assert.assertEquals; /** * Serialization smoke-tests. @@ -34,11 +35,10 @@ public class HLLSerializationTest { public void serializationSmokeTest() throws Exception { final Random random = new Random(RANDOM_SEED); final int randomCount = 250; - final List randoms = new ArrayList(randomCount){{ - for (int i=0; i randoms = new ArrayList(randomCount); + for (int i=0; i Date: Tue, 14 Jul 2015 10:51:07 +0200 Subject: [PATCH 5/6] Cutover to randomizedtesting package so that there's no fixed seed. --- pom.xml | 6 ++-- src/main/java/net/agkn/hll/HLL.java | 6 ++-- src/main/java/net/agkn/hll/util/HLLUtil.java | 6 ++-- .../java/net/agkn/hll/ExplicitHLLTest.java | 11 +++---- .../agkn/hll/IntegrationTestGenerator.java | 33 ++++++++----------- src/test/java/net/agkn/hll/SparseHLLTest.java | 11 ++----- ...igEndianAscendingWordDeserializerTest.java | 10 +++--- .../serialization/HLLSerializationTest.java | 15 ++++----- .../java/net/agkn/hll/util/HLLUtilTest.java | 2 +- 9 files changed, 43 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index 1378824..4e9d12f 100644 --- a/pom.xml +++ b/pom.xml @@ -155,9 +155,9 @@ - junit - junit - 4.10 + com.carrotsearch.randomizedtesting + randomizedtesting-runner + 2.1.14 test diff --git a/src/main/java/net/agkn/hll/HLL.java b/src/main/java/net/agkn/hll/HLL.java index 1ca94fd..688213a 100644 --- a/src/main/java/net/agkn/hll/HLL.java +++ b/src/main/java/net/agkn/hll/HLL.java @@ -427,8 +427,7 @@ private void addRawSparseProbabilistic(final long rawValue) { // NOTE: no +1 as in paper since 0-based indexing final int j = (int)(rawValue & mBitsMask); - assert sparseProbabilisticStorage.containsKey(j); - final byte currentValue = sparseProbabilisticStorage.get(j); + final byte currentValue = sparseProbabilisticStorage.getOrDefault(j, (byte) 0); if(p_w > currentValue) { sparseProbabilisticStorage.put(j, p_w); } @@ -546,8 +545,7 @@ public long cardinality() { double sum = 0; int numberOfZeroes = 0/*"V" in the paper*/; for(int j=0; jBlog post with section on 2^L + * @see "Blog post with section on 2^L" */ private static final double[] TWO_TO_L = new double[(HLL.MAXIMUM_REGWIDTH_PARAM + 1) * (HLL.MAXIMUM_LOG2M_PARAM + 1)]; @@ -178,7 +178,7 @@ public static double smallEstimator(final int m, final int numberOfZeroes) { * @param registerSizeInBits the size of the HLL registers, in bits. * @return the cutoff for the large range correction. * @see #largeEstimator(int, int, double) - * @see Blog post with section on 64 bit hashes and "large range correction" cutoff + * @see "Blog post with section on 64 bit hashes and 'large range correction' cutoff" */ public static double largeEstimatorCutoff(final int log2m, final int registerSizeInBits) { return (TWO_TO_L[(REG_WIDTH_INDEX_MULTIPLIER * registerSizeInBits) + log2m]) / 30.0; @@ -193,7 +193,7 @@ public static double largeEstimatorCutoff(final int log2m, final int registerSiz * @param registerSizeInBits the size of the HLL registers, in bits. * @param estimator the original estimator ("E" in the paper). * @return a corrected cardinality estimate. - * @see Blog post with section on 64 bit hashes and "large range correction" + * @see "Blog post with section on 64 bit hashes and 'large range correction'" */ public static double largeEstimator(final int log2m, final int registerSizeInBits, final double estimator) { final double twoToL = TWO_TO_L[(REG_WIDTH_INDEX_MULTIPLIER * registerSizeInBits) + log2m]; diff --git a/src/test/java/net/agkn/hll/ExplicitHLLTest.java b/src/test/java/net/agkn/hll/ExplicitHLLTest.java index b3f6b53..c942809 100644 --- a/src/test/java/net/agkn/hll/ExplicitHLLTest.java +++ b/src/test/java/net/agkn/hll/ExplicitHLLTest.java @@ -16,23 +16,22 @@ * limitations under the License. */ -import static org.junit.Assert.*; import org.junit.Test; import java.util.HashSet; -import java.util.Random; import net.agkn.hll.serialization.ISchemaVersion; import net.agkn.hll.serialization.SerializationUtil; import com.carrotsearch.hppc.LongHashSet; +import com.carrotsearch.randomizedtesting.RandomizedTest; /** * Tests {@link HLL} of type {@link HLLType#EXPLICIT}. * * @author timon */ -public class ExplicitHLLTest { +public class ExplicitHLLTest extends RandomizedTest { /** * Tests basic set semantics of {@link HLL#addRaw(long)}. */ @@ -179,11 +178,9 @@ public void randomValuesTest() { final HashSet canonical = new HashSet(); final HLL hll = newHLL(explicitThreshold); - final long seed = 1L/*constant so results are reproducible*/; - final Random random = new Random(seed); for(int i=0;inull. * @return the populated HLL. This will never be null. */ - public static HLL generateRandomHLL(final Random random) { - final int randomTypeInt = random.nextInt(HLLType.values().length); + public static HLL generateRandomHLL() { + final int randomTypeInt = randomIntBetween(0, HLLType.values().length - 1); final HLLType type; switch(randomTypeInt) { case 0: @@ -595,10 +590,10 @@ public static HLL generateRandomHLL(final Random random) { final HLL hll = newHLL(HLLType.EMPTY); for(int i=0; i randoms = new ArrayList(randomCount); for (int i=0; i Date: Thu, 16 Jul 2015 17:29:09 +0200 Subject: [PATCH 6/6] Corrected nonsensical same-argument comparison. --- src/test/java/net/agkn/hll/FullHLLTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/agkn/hll/FullHLLTest.java b/src/test/java/net/agkn/hll/FullHLLTest.java index 04e2423..ff32862 100644 --- a/src/test/java/net/agkn/hll/FullHLLTest.java +++ b/src/test/java/net/agkn/hll/FullHLLTest.java @@ -335,7 +335,7 @@ public void toFromBytesTest() { */ private static void assertElementsEqual(final HLL hllA, final HLL hllB) { final BitVector bitVectorA = hllA.probabilisticStorage; - final BitVector bitVectorB = hllA.probabilisticStorage; + final BitVector bitVectorB = hllB.probabilisticStorage; final LongIterator iterA = bitVectorA.registerIterator(); final LongIterator iterB = bitVectorB.registerIterator();