use of com.carrotsearch.hppc.IntByteHashMap in project lucene-solr by apache.
the class SparseHLLTest method assertOneRegisterSet.
/**
* Asserts that only the specified register is set and has the specified value.
*/
private static void assertOneRegisterSet(final HLL hll, final int registerIndex, final byte registerValue) {
final IntByteHashMap sparseProbabilisticStorage = hll.sparseProbabilisticStorage;
assertEquals(sparseProbabilisticStorage.size(), 1);
assertEquals(sparseProbabilisticStorage.get(registerIndex), registerValue);
}
use of com.carrotsearch.hppc.IntByteHashMap in project lucene-solr by apache.
the class SparseHLLTest method randomValuesTest.
/**
* Smoke tests the multisets by adding random values.
*/
@Test
public void randomValuesTest() {
final int log2m = 11;
final int regwidth = 5;
final int sparseThreshold = 256;
for (int run = 0; run < 100; run++) {
final HLL hll = new HLL(log2m, regwidth, 128, /*explicitThreshold, arbitrary, unused*/
sparseThreshold, HLLType.SPARSE);
final IntByteHashMap map = new IntByteHashMap();
for (int i = 0; i < sparseThreshold; i++) {
final long rawValue = RandomizedTest.randomLong();
final short registerIndex = ProbabilisticTestUtil.getRegisterIndex(rawValue, log2m);
final byte registerValue = ProbabilisticTestUtil.getRegisterValue(rawValue, log2m);
if (map.get(registerIndex) < registerValue) {
map.put(registerIndex, registerValue);
}
hll.addRaw(rawValue);
}
for (IntByteCursor c : map) {
final byte expectedRegisterValue = map.get(c.key);
assertRegisterPresent(hll, c.key, expectedRegisterValue);
}
}
}
use of com.carrotsearch.hppc.IntByteHashMap in project lucene-solr by apache.
the class SparseHLLTest method assertElementsEqual.
/**
* Asserts that all registers in the two {@link HLL} instances are identical.
*/
private static void assertElementsEqual(final HLL hllA, final HLL hllB) {
final IntByteHashMap sparseProbabilisticStorageA = hllA.sparseProbabilisticStorage;
final IntByteHashMap sparseProbabilisticStorageB = hllB.sparseProbabilisticStorage;
assertEquals(sparseProbabilisticStorageA.size(), sparseProbabilisticStorageB.size());
for (IntByteCursor c : sparseProbabilisticStorageA) {
assertEquals(sparseProbabilisticStorageA.get(c.key), sparseProbabilisticStorageB.get(c.key));
}
}
use of com.carrotsearch.hppc.IntByteHashMap in project lucene-solr by apache.
the class SparseHLLTest method assertRegisterPresent.
//*************************************************************************
// assertion helpers
/**
* Asserts that the register at the specified index is set to the specified
* value.
*/
private static void assertRegisterPresent(final HLL hll, final int registerIndex, final int registerValue) {
final IntByteHashMap sparseProbabilisticStorage = hll.sparseProbabilisticStorage;
assertEquals(sparseProbabilisticStorage.get(registerIndex), registerValue);
}
Aggregations