Package it.unimi.dsi.fastutil.ints

Examples of it.unimi.dsi.fastutil.ints.Int2ByteOpenHashMap


        final Random random = new Random(seed);

        for(int run=0; run<100; run++) {
            final HLL hll = new HLL(log2m, regwidth, 128/*explicitThreshold, arbitrary, unused*/, sparseThreshold, HLLType.SPARSE);

            final Int2ByteOpenHashMap map = new Int2ByteOpenHashMap();
            map.defaultReturnValue((byte)0);

            for(int i=0; i<sparseThreshold; i++) {
                final long rawValue = random.nextLong();

                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(int key : map.keySet()) {
                final byte expectedRegisterValue = map.get(key);
                assertRegisterPresent(hll, key, expectedRegisterValue);
            }
        }
    }
View Full Code Here


     * value.
     */
    private static void assertRegisterPresent(final HLL hll,
                                              final int registerIndex,
                                              final int registerValue) {
        final Int2ByteOpenHashMap sparseProbabilisticStorage = (Int2ByteOpenHashMap)getInternalState(hll, "sparseProbabilisticStorage");
        assertEquals(sparseProbabilisticStorage.get(registerIndex), registerValue);
    }
View Full Code Here

     * 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 Int2ByteOpenHashMap sparseProbabilisticStorage = (Int2ByteOpenHashMap)getInternalState(hll, "sparseProbabilisticStorage");
        assertEquals(sparseProbabilisticStorage.size(), 1);
        assertEquals(sparseProbabilisticStorage.get(registerIndex), registerValue);
    }
View Full Code Here

    /**
     * Asserts that all registers in the two {@link HLL} instances are identical.
     */
    private static void assertElementsEqual(final HLL hllA, final HLL hllB) {
        final Int2ByteOpenHashMap sparseProbabilisticStorageA = (Int2ByteOpenHashMap)getInternalState(hllA, "sparseProbabilisticStorage");
        final Int2ByteOpenHashMap sparseProbabilisticStorageB = (Int2ByteOpenHashMap)getInternalState(hllB, "sparseProbabilisticStorage");
        assertEquals(sparseProbabilisticStorageA.size(), sparseProbabilisticStorageB.size());
        for(final int index : sparseProbabilisticStorageA.keySet()) {
            assertEquals(sparseProbabilisticStorageA.get(index), sparseProbabilisticStorageB.get(index));
        }
    }
View Full Code Here

                break;
            case EXPLICIT:
                this.explicitStorage = new LongOpenHashSet();
                break;
            case SPARSE:
                this.sparseProbabilisticStorage = new Int2ByteOpenHashMap();
                break;
            case FULL:
                this.probabilisticStorage = new BitVector(regwidth, m);
                break;
            default:
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.ints.Int2ByteOpenHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.