List of usage examples for com.google.common.util.concurrent AtomicLongMap addAndGet
public long addAndGet(K key, long delta)
From source file:com.cloudera.oryx.app.mllib.rdf.RDFUpdate.java
private static AtomicLongMap<Integer> merge(AtomicLongMap<Integer> a, AtomicLongMap<Integer> b) { for (Map.Entry<Integer, Long> e : b.asMap().entrySet()) { a.addAndGet(e.getKey(), e.getValue()); }/* w ww . j a v a 2 s. c om*/ return a; }
From source file:org.mondemand.Client.java
/** * Given context&Stats map, increment according to context and key/value * @param context context//from ww w.ja v a 2s .co m * @param keyType key * @param value value * @throws MondemandException */ public void increment(ContextList context, String keyType, long value) throws MondemandException { if (!isKeyValid(keyType)) { throw new MondemandException("key is invalid: " + keyType); } // Note: add could be lost due to a race condition but no // synchronization is required. AtomicLongMap<String> stats = contextStats.get(context); if (stats == null) { AtomicLongMap<String> newStats = AtomicLongMap.create(); stats = contextStats.putIfAbsent(context, newStats); if (stats == null) { stats = newStats; } } stats.addAndGet(keyType, value); }