Search in sources :

Example 1 with IntDoubleCursor

use of com.carrotsearch.hppc.cursors.IntDoubleCursor in project drill by apache.

the class OperatorStats method mergeMetrics.

/**
   * OperatorStats merger - to merge stats from other OperatorStats
   * this is needed in case some processing is multithreaded that needs to have
   * separate OperatorStats to deal with
   * WARN - this will only work for metrics that can be added
   * @param from - OperatorStats from where to merge to "this"
   * @return OperatorStats - for convenience so one can merge multiple stats in one go
   */
public OperatorStats mergeMetrics(OperatorStats from) {
    final IntLongHashMap fromMetrics = from.longMetrics;
    final Iterator<IntLongCursor> iter = fromMetrics.iterator();
    while (iter.hasNext()) {
        final IntLongCursor next = iter.next();
        longMetrics.putOrAdd(next.key, next.value, next.value);
    }
    final IntDoubleHashMap fromDMetrics = from.doubleMetrics;
    final Iterator<IntDoubleCursor> iterD = fromDMetrics.iterator();
    while (iterD.hasNext()) {
        final IntDoubleCursor next = iterD.next();
        doubleMetrics.putOrAdd(next.key, next.value, next.value);
    }
    return this;
}
Also used : IntLongHashMap(com.carrotsearch.hppc.IntLongHashMap) IntDoubleHashMap(com.carrotsearch.hppc.IntDoubleHashMap) IntLongCursor(com.carrotsearch.hppc.cursors.IntLongCursor) IntDoubleCursor(com.carrotsearch.hppc.cursors.IntDoubleCursor)

Aggregations

IntDoubleHashMap (com.carrotsearch.hppc.IntDoubleHashMap)1 IntLongHashMap (com.carrotsearch.hppc.IntLongHashMap)1 IntDoubleCursor (com.carrotsearch.hppc.cursors.IntDoubleCursor)1 IntLongCursor (com.carrotsearch.hppc.cursors.IntLongCursor)1