Search in sources :

Example 6 with DimensionObject

use of org.apache.apex.malhar.lib.logs.DimensionObject in project apex-malhar by apache.

the class DimensionOperatorUnifier method endWindow.

@Override
public void endWindow() {
    Map<String, DimensionObject<String>> outputAggregationsObject;
    for (Entry<String, Map<String, Map<AggregateOperation, Number>>> keys : unifiedCache.entrySet()) {
        String key = keys.getKey();
        Map<String, Map<AggregateOperation, Number>> dimValues = keys.getValue();
        for (Entry<String, Map<AggregateOperation, Number>> dimValue : dimValues.entrySet()) {
            String dimValueName = dimValue.getKey();
            Map<AggregateOperation, Number> operations = dimValue.getValue();
            outputAggregationsObject = new HashMap<String, DimensionObject<String>>();
            for (Entry<AggregateOperation, Number> operation : operations.entrySet()) {
                AggregateOperation aggrOperationType = operation.getKey();
                Number aggr = operation.getValue();
                String outKey = key + "." + aggrOperationType.name();
                DimensionObject<String> outDimObj = new DimensionObject<String>(new MutableDouble(aggr), dimValueName);
                outputAggregationsObject.put(outKey, outDimObj);
            }
            aggregationsOutput.emit(outputAggregationsObject);
        }
    }
}
Also used : MutableDouble(org.apache.commons.lang.mutable.MutableDouble) DimensionObject(org.apache.apex.malhar.lib.logs.DimensionObject) Map(java.util.Map) HashMap(java.util.HashMap) AggregateOperation(com.datatorrent.apps.logstream.LogstreamUtil.AggregateOperation)

Aggregations

DimensionObject (org.apache.apex.malhar.lib.logs.DimensionObject)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 MutableDouble (org.apache.commons.lang.mutable.MutableDouble)4 CollectorTestSink (org.apache.apex.malhar.lib.testbench.CollectorTestSink)3 Test (org.junit.Test)3 AggregateOperation (com.datatorrent.apps.logstream.LogstreamUtil.AggregateOperation)2 LogstreamPropertyRegistry (com.datatorrent.apps.logstream.PropertyRegistry.LogstreamPropertyRegistry)2 DTThrowable (com.datatorrent.netlet.util.DTThrowable)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SelectOperator (org.apache.apex.malhar.contrib.misc.streamquery.SelectOperator)1 ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)1 MultiWindowDimensionAggregation (org.apache.apex.malhar.lib.logs.MultiWindowDimensionAggregation)1 Counter (org.apache.apex.malhar.lib.stream.Counter)1 JsonByteArrayOperator (org.apache.apex.malhar.lib.stream.JsonByteArrayOperator)1 DimensionTimeBucketSumOperator (org.apache.apex.malhar.lib.util.DimensionTimeBucketSumOperator)1