Search in sources :

Example 6 with Aggregate

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;
}
Also used : Aggregate(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)

Example 7 with 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;
}
Also used : GPOMutable(org.apache.apex.malhar.lib.appdata.gpo.GPOMutable) SerdeListGPOMutable(org.apache.apex.malhar.lib.appdata.gpo.SerdeListGPOMutable) Aggregate(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)

Example 8 with Aggregate

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;
}
Also used : Aggregate(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)

Example 9 with 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));
        }
    }
}
Also used : EventKey(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey) Aggregate(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate) Map(java.util.Map)

Example 10 with Aggregate

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);
}
Also used : GPOMutable(org.apache.apex.malhar.lib.appdata.gpo.GPOMutable) EventKey(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey) Aggregate(org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)

Aggregations

Aggregate (org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)10 GPOMutable (org.apache.apex.malhar.lib.appdata.gpo.GPOMutable)4 EventKey (org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey)3 Map (java.util.Map)1 SerdeListGPOMutable (org.apache.apex.malhar.lib.appdata.gpo.SerdeListGPOMutable)1