List of usage examples for org.apache.commons.lang.mutable MutableDouble shortValue
public short shortValue()
From source file:com.datatorrent.lib.math.SumMap.java
/** * Emits on all ports that are connected. Data is precomputed during process on input port * endWindow just emits it for each key/*from w w w. j a v a 2 s . co m*/ * Clears the internal data before return */ @Override public void endWindow() { HashMap<K, V> tuples = new HashMap<K, V>(); HashMap<K, Double> dtuples = new HashMap<K, Double>(); HashMap<K, Integer> ituples = new HashMap<K, Integer>(); HashMap<K, Float> ftuples = new HashMap<K, Float>(); HashMap<K, Long> ltuples = new HashMap<K, Long>(); HashMap<K, Short> stuples = new HashMap<K, Short>(); for (Map.Entry<K, MutableDouble> e : sums.entrySet()) { K key = e.getKey(); MutableDouble val = e.getValue(); tuples.put(key, getValue(val.doubleValue())); dtuples.put(key, val.doubleValue()); ituples.put(key, val.intValue()); ltuples.put(key, val.longValue()); stuples.put(key, val.shortValue()); ftuples.put(key, val.floatValue()); } sum.emit(tuples); sumDouble.emit(dtuples); sumInteger.emit(ituples); sumFloat.emit(ftuples); sumLong.emit(ltuples); sumShort.emit(stuples); clearCache(); }
From source file:com.datatorrent.lib.math.SumCountMap.java
/** * Emits on all ports that are connected. Data is precomputed during process * on input port endWindow just emits it for each key Clears the internal data * before return/* www. ja v a 2s.co m*/ */ @Override public void endWindow() { // Should allow users to send each key as a separate tuple to load balance // This is an aggregate node, so load balancing would most likely not be // needed HashMap<K, V> tuples = new HashMap<K, V>(); HashMap<K, Integer> ctuples = new HashMap<K, Integer>(); HashMap<K, Double> dtuples = new HashMap<K, Double>(); HashMap<K, Integer> ituples = new HashMap<K, Integer>(); HashMap<K, Float> ftuples = new HashMap<K, Float>(); HashMap<K, Long> ltuples = new HashMap<K, Long>(); HashMap<K, Short> stuples = new HashMap<K, Short>(); for (Map.Entry<K, MutableDouble> e : sums.entrySet()) { K key = e.getKey(); MutableDouble val = e.getValue(); tuples.put(key, getValue(val.doubleValue())); dtuples.put(key, val.doubleValue()); ituples.put(key, val.intValue()); ftuples.put(key, val.floatValue()); ltuples.put(key, val.longValue()); stuples.put(key, val.shortValue()); // ctuples.put(key, counts.get(e.getKey()).toInteger()); MutableInt c = counts.get(e.getKey()); if (c != null) { ctuples.put(key, c.toInteger()); } } sum.emit(tuples); sumDouble.emit(dtuples); sumInteger.emit(ituples); sumLong.emit(ltuples); sumShort.emit(stuples); sumFloat.emit(ftuples); count.emit(ctuples); clearCache(); }