@Override public boolean process(Node node) { sumOfWeights.addAndGet(node.weightedCount); actualNodeCount.incrementAndGet(); if (node.weightedCount >= ZERO_WEIGHT_THRESHOLD) { actualNonZeroNodeCount.incrementAndGet(); } return true; } });
public double increment(String key, double val) { return doubleCounters.computeIfAbsent(key, k -> new AtomicDouble()).addAndGet(val); }
@Override public AtomicDouble update(Number object, AtomicDouble cache, Object... others) { // TODO Auto-generated method stub if (cache == null) { cache = new AtomicDouble(0.0); } if (object != null) { cache.addAndGet(object.doubleValue()); } return cache; }
choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get())); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); return a.put(new JSONObject().put(aggregator_as, sum.get() / choices.length())); if (aggregator.startsWith("PERCENT(") && aggregator.endsWith(")")) { final AtomicDouble sum = new AtomicDouble(0.0d); String c = aggregator.substring(8, aggregator.length() - 1); choices.forEach(json -> sum.addAndGet(((JSONObject) json).getDouble(c))); choices.forEach(json -> a.put(new JSONObject() .put(aggregator_as, 100.0d * ((JSONObject) json).getDouble(c) / sum.get())
/** addAndGet adds given value to current, and returns current value */ public void testAddAndGet() { for (double x : VALUES) { for (double y : VALUES) { AtomicDouble a = new AtomicDouble(x); double z = a.addAndGet(y); assertBitEquals(x + y, z); assertBitEquals(x + y, a.get()); } } }
@Override public boolean process(Node node) { while (iterator.hasNext() && iterator.peek() <= node.getUpperBound()) { double bucketCount = sum.get() - lastSum.get(); Bucket bucket = new Bucket(bucketCount / normalizationFactor, bucketWeightedSum.get() / bucketCount); builder.add(bucket); lastSum.set(sum.get()); bucketWeightedSum.set(0); iterator.next(); } bucketWeightedSum.addAndGet(node.getMiddle() * node.weightedCount); sum.addAndGet(node.weightedCount); return iterator.hasNext(); } });
@Override public boolean process(Node node) { sumOfWeights.addAndGet(node.weightedCount); actualNodeCount.incrementAndGet(); if (node.weightedCount > ZERO_WEIGHT_THRESHOLD) { actualNonZeroNodeCount.incrementAndGet(); } return true; } });
public boolean process(Node node) { while (iterator.hasNext() && iterator.peek() <= node.getUpperBound()) { double bucketCount = sum.get() - lastSum.get(); Bucket bucket = new Bucket( bucketCount / normalizationFactor, bucketWeightedSum.get() / bucketCount); builder.add(bucket); lastSum.set(sum.get()); bucketWeightedSum.set(0); iterator.next(); } bucketWeightedSum.addAndGet(node.getMiddle() * node.weightedCount); sum.addAndGet(node.weightedCount); return iterator.hasNext(); } });
/** * Measures the average before the given {@code time} and updates * it with the given {@code amount}. */ public double updateAt(long time, double amount) { tick(time); total.addAndGet(amount); return currentAverage * 1e9; }
@Override public void call(CellAndDistance cell) { metrics.totalNauticalMiles.addAndGet(cell.getDistanceNm()); } };
public void addReadBytes(long readBytes, boolean propigateEvent) { double val = this.readBytes.addAndGet(readBytes); this.addRIO(true); if (val < 0) this.readBytes.set(0); }
@Override public void addSample(double sample) { samples++; if (interval.contains(sample)) { // Selection of the index int index = getIndex(sample); // Update of the bin count bins[index].addAndGet(1); } }
public void addVirtualBytesWritten(long virtualBytesWritten, boolean propigateEvent) { this.addWIO(true); double val = this.virtualBytesWritten.addAndGet(virtualBytesWritten); if (val < 0) this.virtualBytesWritten.set(0); }
/** * {@inheritDoc} */ @Override public double updateModel(DataOnMemory<DynamicDataInstance> batch) { this.sumSS.sum(batch.stream() .map(dataInstance -> computeCountSufficientStatistics(this.efBayesianNetwork, dataInstance)) .reduce(DynamicPartialSufficientSatistics::sumNonStateless).get()); dataInstanceCount.addAndGet(batch.getNumberOfDataInstances()); return Double.NaN; }
@Override public BatchWriteItemResult measureConsumedCapacity(BatchWriteItemResult result) { consumed.addAndGet(result.getConsumedCapacity() == null ? 0 : getConsumedCapacityForTable(result.getConsumedCapacity())); return result; } }
@Override public BatchGetItemResult measureConsumedCapacity(BatchGetItemResult result) { consumed.addAndGet(result.getConsumedCapacity() == null ? 0 : getConsumedCapacityForTable(result.getConsumedCapacity())); return result; } }
@Override public PutItemResult measureConsumedCapacity(PutItemResult result) { ConsumedCapacity consumedCapacity = result.getConsumedCapacity(); if (consumedCapacity != null && consumedCapacity.getCapacityUnits() != null) { consumed.addAndGet(result.getConsumedCapacity().getCapacityUnits()); } return result; } }
@Override public GetItemResult measureConsumedCapacity(GetItemResult result) { ConsumedCapacity consumedCapacity = result.getConsumedCapacity(); if (consumedCapacity != null && consumedCapacity.getCapacityUnits() != null) { consumed.addAndGet(result.getConsumedCapacity().getCapacityUnits()); } return result; } }
@Override public PutItemResult measureConsumedCapacity(PutItemResult result) { ConsumedCapacity consumedCapacity = result.getConsumedCapacity(); if (consumedCapacity != null && consumedCapacity.getCapacityUnits() != null) { consumed.addAndGet(result.getConsumedCapacity().getCapacityUnits()); } return result; } }