use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey in project apex-malhar by apache.
the class AbstractTopBottomAggregator method updateAggregate.
/**
* update existed sub aggregate.
* The sub aggregates which kept in composite aggregate as candidate could be changed. synchronize the value with
* input aggregates.
*
* @param resultAggregate
* @param valueField
* @param inputSubEventKeys
* @param inputAggregatesRepo
*/
@SuppressWarnings("unchecked")
protected void updateAggregate(Aggregate resultAggregate, String valueField, Set<EventKey> inputSubEventKeys, Map<EventKey, Aggregate> inputAggregatesRepo) {
Map<String, Object> resultAggregateFieldToValue = (Map<String, Object>) resultAggregate.getAggregates().getFieldObject(valueField);
if (resultAggregateFieldToValue == null) {
return;
}
for (EventKey inputSubEventKey : inputSubEventKeys) {
Aggregate inputSubAggregate = inputAggregatesRepo.get(inputSubEventKey);
String mapKey = getStoreMapKey(inputSubAggregate.getEventKey(), resultAggregate.getEventKey().getKey().getFieldDescriptor().getFieldList());
// Aggregate existedAggregate = existedSubEventKeyToAggregate.get(inputSubEventKey);
if (resultAggregateFieldToValue.get(mapKey) != null) {
resultAggregateFieldToValue.put(mapKey, inputSubAggregate.getAggregates().getField(valueField));
}
}
}
use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey in project apex-malhar by apache.
the class AggregatorCount method getGroup.
@Override
public Aggregate getGroup(InputEvent src, int aggregatorIndex) {
src.used = true;
GPOMutable aggregates = new GPOMutable(context.aggregateDescriptor);
GPOMutable keys = new GPOMutable(context.keyDescriptor);
GPOUtils.indirectCopy(keys, src.getKeys(), context.indexSubsetKeys);
EventKey eventKey = createEventKey(src, context, aggregatorIndex);
long[] longFields = aggregates.getFieldsLong();
for (int index = 0; index < longFields.length; index++) {
longFields[index] = 0;
}
return new Aggregate(eventKey, aggregates);
}
Aggregations