/** * Adds <code>incrementValue</code> to any existing value for the given <code>key</code> * or inserts <code>incrementValue</code> if <code>key</code> did not previously exist. * * @param key The key of the value to adjust. * @param incrementValue The value to put or add to the existing value if <code>key</code> exists. * @return Returns the current value associated with <code>key</code> (after changes). */ @Override public double addTo(int key, double incrementValue) { return putOrAdd(key, incrementValue, incrementValue); }
/** * Adds <code>incrementValue</code> to any existing value for the given <code>key</code> * or inserts <code>incrementValue</code> if <code>key</code> did not previously exist. * * @param key The key of the value to adjust. * @param incrementValue The value to put or add to the existing value if <code>key</code> exists. * @return Returns the current value associated with <code>key</code> (after changes). */ @Override public double addTo(int key, double incrementValue) { return putOrAdd(key, incrementValue, incrementValue); }
/** * Add a double value to the existing value. Creates the stat * (with an initial value of zero) if the stat does not yet * exist. * * @param metric the metric to update * @param value the value to add to the existing value */ public void addDoubleStat(MetricDef metric, double value){ doubleMetrics.putOrAdd(metric.metricId(), value, value); }
public void addDoubleStat(MetricDef metric, double value){ doubleMetrics.putOrAdd(metric.metricId(), value, value); }
/** * 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; }
/** * 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; }