Search in sources :

Example 1 with HighLow

use of org.apache.apex.malhar.lib.util.HighLow in project apex-malhar by apache.

the class Range method endWindow.

/**
 * Emits the range. If no tuple was received in the window, no emit is done
 * Clears the internal data before return
 */
@Override
public void endWindow() {
    if ((low != null) && (high != null)) {
        HighLow tuple = new HighLow(getValue(high.doubleValue()), getValue(low.doubleValue()));
        range.emit(tuple);
    }
    high = null;
    low = null;
}
Also used : HighLow(org.apache.apex.malhar.lib.util.HighLow)

Example 2 with HighLow

use of org.apache.apex.malhar.lib.util.HighLow in project apex-malhar by apache.

the class MultiWindowRangeKeyVal method endWindow.

/**
 * Emits range for each key at application window boundary. If no data is received, no emit is done
 * Clears the internal data before return
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void endWindow() {
    boolean emit = (++windowCount) % windowSize == 0;
    if (!emit) {
        return;
    }
    for (Map.Entry<K, V> e : high.entrySet()) {
        HighLow<V> hl = new HighLow<V>();
        hl.setHigh(getValue(e.getValue().doubleValue()));
        // cannot be null
        hl.setLow(getValue(low.get(e.getKey()).doubleValue()));
        range.emit(new KeyValPair(e.getKey(), hl));
    }
    clearCache();
}
Also used : HighLow(org.apache.apex.malhar.lib.util.HighLow) KeyValPair(org.apache.apex.malhar.lib.util.KeyValPair) Map(java.util.Map)

Aggregations

HighLow (org.apache.apex.malhar.lib.util.HighLow)2 Map (java.util.Map)1 KeyValPair (org.apache.apex.malhar.lib.util.KeyValPair)1