use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachKeyInParallel.
/**
* forEachKeyInParallel traverses all keys
*/
public void testForEachKeyInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachKey(1L, (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachEntrySequentially.
/**
* forEachEntrySequentially traverses all entries
*/
public void testForEachEntrySequentially() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachEntry(Long.MAX_VALUE, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachInParallel.
/**
* forEachInParallel traverses all mappings
*/
public void testForEachInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEach(1L, (Long x, Long y) -> adder.add(x.longValue() + y.longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testForEachEntryInParallel.
/**
* forEachEntryInParallel traverses all entries
*/
public void testForEachEntryInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue()));
assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testMappedForEachKeyInParallel.
/**
* Mapped forEachKeyInParallel traverses the given
* transformations of all keys
*/
public void testMappedForEachKeyInParallel() {
LongAdder adder = new LongAdder();
ConcurrentHashMap<Long, Long> m = longMap();
m.forEachKey(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1) / 2);
}
Aggregations