/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
@Override public void clear() { sum.setValue(0); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
/** * Sets the value from any Number instance. * * @param value the value to set, not null * @throws NullPointerException if the object is null * @throws ClassCastException if the type is not a {@link Number} */ public void setValue(Object value) { setValue(((Number) value).doubleValue()); }
public void clear() { sum.setValue(0); count.setValue(0); } }
public void endWindow() { Map<String, Object> summary = new HashMap<String, Object>(); double avg; if (txnsInLastSecond.longValue() == 0) { avg = 0; } else { avg = amtInLastSecond.doubleValue() / txnsInLastSecond.longValue(); } summary.put("totalTxns", totalTxns); summary.put("txnsInLastSecond", txnsInLastSecond); summary.put("amtInLastSecond", amtFormatter.format(amtInLastSecond)); summary.put("avgAmtInLastSecond", amtFormatter.format(avg)); summaryTxnOutputPort.emit(summary); txnsInLastSecond.setValue(0); amtInLastSecond.setValue(0); }
@Override public void endWindow() { for (AverageAlertData data : alerts) { try { avgAlertOutputPort.emit(JsonUtils.toJson(data)); } catch (IOException e) { logger.warn("Exception while converting object to JSON", e); } } alerts.clear(); for (Map.Entry<MerchantKey, MutableDouble> entry : currentSMAMap.entrySet()) { MerchantKey key = entry.getKey(); MutableDouble currentSma = entry.getValue(); MutableDouble lastSma = lastSMAMap.get(key); if (lastSma == null) { lastSma = new MutableDouble(currentSma.doubleValue()); lastSMAMap.put(key, lastSma); } else { lastSma.setValue(currentSma.getValue()); } } }
alert.emit(otuple); val.setValue(e.getValue().doubleValue());
alert.emit(otuple); val.setValue(e.getValue().doubleValue());
@Override public void process(KeyValPair<MerchantKey, Double> tuple) { MutableDouble currentSma = currentSMAMap.get(tuple.getKey()); if (currentSma == null) { // first sma for the given key double sma = tuple.getValue(); currentSMAMap.put(tuple.getKey(), new MutableDouble(sma)); //lastSMAMap.put(tuple.getKey(), new MutableDouble(sma)); } else { // move the current SMA value to the last SMA Map //lastSMAMap.get(tuple.getKey()).setValue(currentSma.getValue()); currentSma.setValue(tuple.getValue()); // update the current SMA value } }
/** * Process each key to store the value. If same key appears again update * with latest value. */ @Override public void process(KeyValPair<K, V> tuple) { if (tuple.getValue().doubleValue() != 0.0) { // Avoid divide by zero, Emit // an error tuple? MutableDouble val = basemap.get(tuple.getKey()); if (val == null) { val = new MutableDouble(0.0); basemap.put(cloneKey(tuple.getKey()), val); } val.setValue(tuple.getValue().doubleValue()); } } };
/** * Process each key to store the value. If same key appears again update * with latest value. */ @Override public void process(KeyValPair<K, V> tuple) { if (tuple.getValue().doubleValue() != 0.0) { // Avoid divide by zero, Emit // an error tuple? MutableDouble val = basemap.get(tuple.getKey()); if (val == null) { val = new MutableDouble(0.0); basemap.put(cloneKey(tuple.getKey()), val); } val.setValue(tuple.getValue().doubleValue()); } } };
/** * Used to accumulate store metrics across multiple regions in a region * server. These metrics are not "persistent", i.e. we keep overriding them * on every update instead of incrementing, so we need to accumulate them in * a temporary map before pushing them to the global metric collection. * @param tmpMap a temporary map for accumulating store metrics * @param storeMetricType the store metric type to increment * @param val the value to add to the metric */ public void accumulateStoreMetric(final Map<String, MutableDouble> tmpMap, StoreMetricType storeMetricType, double val) { final String key = getStoreMetricName(storeMetricType); if (tmpMap.get(key) == null) { tmpMap.put(key, new MutableDouble(val)); } else { tmpMap.get(key).add(val); } if (this == ALL_SCHEMA_METRICS) { // also compute the max value across all Stores on this server final String maxKey = getStoreMetricNameMax(storeMetricType); MutableDouble cur = tmpMap.get(maxKey); if (cur == null) { tmpMap.put(maxKey, new MutableDouble(val)); } else if (cur.doubleValue() < val) { cur.setValue(val); } } else { ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val); } }
alert.emit(otuple); val.setValue(tval);
alert.emit(otuple); val.setValue(tval);