use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate in project apex-malhar by apache.
the class AbstractIncrementalAggregator method getGroup.
@Override
public Aggregate getGroup(InputEvent src, int aggregatorIndex) {
src.used = true;
Aggregate aggregate = createAggregate(src, context, aggregatorIndex);
return aggregate;
}
use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate in project apex-malhar by apache.
the class AggregatorCumSum method getGroup.
@Override
public Aggregate getGroup(InputEvent src, int aggregatorIndex) {
src.used = true;
Aggregate agg = createAggregate(src, context, aggregatorIndex);
GPOUtils.indirectCopy(agg.getAggregates(), src.getAggregates(), context.indexSubsetAggregates);
GPOMutable metaData = new GPOMutable(getMetaDataDescriptor());
GPOMutable fullKey = new GPOMutable(src.getKeys());
if (context.inputTimestampIndex >= 0) {
fullKey.getFieldsLong()[context.inputTimestampIndex] = -1L;
}
List<GPOMutable> keys = Lists.newArrayList(fullKey);
GPOMutable value = new GPOMutable(agg.getAggregates());
List<GPOMutable> values = Lists.newArrayList(value);
metaData.getFieldsObject()[KEY_FD_INDEX] = fullKey.getFieldDescriptor();
metaData.getFieldsObject()[AGGREGATE_FD_INDEX] = value.getFieldDescriptor();
metaData.getFieldsObject()[KEYS_INDEX] = keys;
metaData.getFieldsObject()[AGGREGATES_INDEX] = values;
agg.setMetaData(metaData);
return agg;
}
use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate in project apex-malhar by apache.
the class AggregatorMax method getGroup.
@Override
public Aggregate getGroup(InputEvent src, int aggregatorIndex) {
Aggregate aggregate = super.getGroup(src, aggregatorIndex);
GPOUtils.indirectCopy(aggregate.getAggregates(), src.getAggregates(), context.indexSubsetAggregates);
return aggregate;
}
use of org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate 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.Aggregate 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