Search in sources :

Example 6 with EventKey

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));
        }
    }
}
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 7 with EventKey

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);
}
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

EventKey (org.apache.apex.malhar.lib.dimensions.DimensionsEvent.EventKey)7 GPOMutable (org.apache.apex.malhar.lib.appdata.gpo.GPOMutable)6 Aggregate (org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate)3 FieldsDescriptor (org.apache.apex.malhar.lib.appdata.schemas.FieldsDescriptor)2 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Map (java.util.Map)1 CustomTimeBucket (org.apache.apex.malhar.lib.appdata.schemas.CustomTimeBucket)1 Type (org.apache.apex.malhar.lib.appdata.schemas.Type)1 Test (org.junit.Test)1