本文整理汇总了Java中org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate.getAggregates方法的典型用法代码示例。如果您正苦于以下问题:Java Aggregate.getAggregates方法的具体用法?Java Aggregate.getAggregates怎么用?Java Aggregate.getAggregates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate
的用法示例。
在下文中一共展示了Aggregate.getAggregates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aggregate
import org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate; //导入方法依赖的package包/类
/**
* The result keep a list of object for each aggregate value
* The value of resultAggregate should keep a list of inputEventKey(the value can be get from cache or load) or a map
* from inputEventKey to the value instead of just a list of aggregate value. As the value could be changed in
* current window, and this change should be applied.
*
* precondition: resultAggregate.eventKey matches with inputSubEventKeys
* notes: this algorithm only support TOP for positive values and BOTTOM for negative values
*/
@Override
public void aggregate(Aggregate resultAggregate, Set<EventKey> inputSubEventKeys,
Map<EventKey, Aggregate> inputAggregatesRepo)
{
//there are problem for composite's value field descriptor, just ignore now.
GPOMutable resultGpo = resultAggregate.getAggregates();
final List<String> compositeFieldList = resultAggregate.getEventKey().getKey().getFieldDescriptor().getFieldList();
//Map<EventKey, Aggregate> existedSubEventKeyToAggregate = Maps.newHashMap();
for (String valueField : resultGpo.getFieldDescriptor().getFieldList()) {
//the resultGpo keep a list of sub aggregates
updateAggregate(resultAggregate, valueField, inputSubEventKeys, inputAggregatesRepo);
//compare the existed sub aggregates with the new input aggregates to update the list
for (EventKey eventKey : inputSubEventKeys) {
aggregate(compositeFieldList, resultGpo, eventKey, inputAggregatesRepo.get(eventKey).getAggregates());
}
}
}
示例2: getGroup
import org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate; //导入方法依赖的package包/类
@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;
}
示例3: getGroup
import org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate; //导入方法依赖的package包/类
@Override
public Aggregate getGroup(InputEvent src, int aggregatorIndex)
{
src.used = true;
Aggregate aggregate = createAggregate(src,
context,
aggregatorIndex);
GPOMutable value = aggregate.getAggregates();
GPOUtils.zeroFillNumeric(value);
return aggregate;
}
示例4: aggregate
import org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate; //导入方法依赖的package包/类
@Override
public void aggregate(Aggregate dest, Aggregate src)
{
GPOMutable destAggs = dest.getAggregates();
GPOMutable srcAggs = src.getAggregates();
aggregateAggs(destAggs, srcAggs);
}
示例5: setStatementParameters
import org.apache.apex.malhar.lib.dimensions.DimensionsEvent.Aggregate; //导入方法依赖的package包/类
/**
* Sets the parameters on the {@link java.sql.PreparedStatement} based on the
* values in the given {@link Aggregate}.
*
* @param aggregate
* The {@link Aggregate} whose values will be set on the
* corresponding {@link java.sql.PreparedStatement}.
*/
private void setStatementParameters(Aggregate aggregate)
{
EventKey eventKey = aggregate.getEventKey();
int ddID = eventKey.getDimensionDescriptorID();
int aggID = eventKey.getAggregatorID();
LOG.info("Setting statement params {} {}", ddID, aggID);
FieldsDescriptor keyFD = schema.getDimensionsDescriptorIDToKeyDescriptor().get(ddID);
FieldsDescriptor aggFD = schema.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(ddID)
.get(aggID);
GPOMutable key = eventKey.getKey();
key.setFieldDescriptor(keyFD);
GPOMutable value = aggregate.getAggregates();
value.setFieldDescriptor(aggFD);
int qCounter = 1;
PreparedStatement ps = ddIDToAggIDToStatement.get(ddID).get(aggID);
try {
qCounter = setParams(ps, key, qCounter, true);
setParams(ps, value, qCounter, false);
ps.addBatch();
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
}