Search in sources :

Example 51 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.

the class ConcurrentHashMap8Test method testMappedForEachValueInParallel.

/**
     * Mapped forEachValueInParallel traverses the given
     * transformations of all values
     */
public void testMappedForEachValueInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(1L, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Example 52 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.

the class ConcurrentHashMap8Test method testMappedForEachEntryInParallel.

/**
     * Mapped forEachEntryInParallel traverses the given
     * transformations of all entries
     */
public void testMappedForEachEntryInParallel() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachEntry(1L, (Map.Entry<Long, Long> e) -> Long.valueOf(e.getKey().longValue() + e.getValue().longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Example 53 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.

the class ConcurrentHashMap8Test method testForEachValueSequentially.

/**
     * forEachValueSequentially traverses all values
     */
public void testForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), SIZE * (SIZE - 1));
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Example 54 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.

the class ConcurrentHashMap8Test method testMappedForEachSequentially.

/**
     * Mapped forEachSequentially traverses the given
     * transformations of all mappings
     */
public void testMappedForEachSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEach(Long.MAX_VALUE, (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Example 55 with LongAdder

use of java.util.concurrent.atomic.LongAdder in project mapdb by jankotek.

the class ConcurrentHashMap8Test method testMappedForEachValueSequentially.

/**
     * Mapped forEachValueSequentially traverses the given
     * transformations of all values
     */
public void testMappedForEachValueSequentially() {
    LongAdder adder = new LongAdder();
    ConcurrentHashMap<Long, Long> m = longMap();
    m.forEachValue(Long.MAX_VALUE, (Long x) -> Long.valueOf(4 * x.longValue()), (Long x) -> adder.add(x.longValue()));
    assertEquals(adder.sum(), 4 * SIZE * (SIZE - 1));
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder)

Aggregations

LongAdder (java.util.concurrent.atomic.LongAdder)92 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)16 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 Random (java.util.Random)13 ExecutorService (java.util.concurrent.ExecutorService)10 SplittableRandom (java.util.SplittableRandom)9 HashMap (java.util.HashMap)7 Map (java.util.Map)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 Theory (org.junit.experimental.theories.Theory)6 UUID (java.util.UUID)5 ArrayList (java.util.ArrayList)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Ignite (org.apache.ignite.Ignite)4 IgniteUuid (org.apache.ignite.lang.IgniteUuid)4 Metric (org.springframework.boot.actuate.metrics.Metric)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 Callable (java.util.concurrent.Callable)3 CountDownLatch (java.util.concurrent.CountDownLatch)3