Search in sources :

Example 1 with Monitor

use of org.neo4j.collection.primitive.hopscotch.HopScotchHashingAlgorithm.Monitor in project neo4j by neo4j.

the class HopScotchHashingAlgorithmTest method figureOutGrowthThreshold.

private int figureOutGrowthThreshold() {
    final AtomicBoolean grew = new AtomicBoolean();
    Monitor monitor = new Monitor.Adapter() {

        @Override
        public boolean tableGrew(int fromCapacity, int toCapacity, int currentSize) {
            grew.set(true);
            return true;
        }
    };
    try (PrimitiveLongSet set = new PrimitiveLongHashSet(new LongKeyTable<>(DEFAULT_H, VALUE_MARKER), VALUE_MARKER, monitor)) {
        int i = 0;
        for (i = 0; !grew.get(); i++) {
            set.add(i * 3);
        }
        return i;
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Monitor(org.neo4j.collection.primitive.hopscotch.HopScotchHashingAlgorithm.Monitor) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 PrimitiveLongSet (org.neo4j.collection.primitive.PrimitiveLongSet)1 Monitor (org.neo4j.collection.primitive.hopscotch.HopScotchHashingAlgorithm.Monitor)1