use of storm.trident.Stream in project jstorm by alibaba.
the class TridentMinMaxOfDevicesTest method testTridentMinMaxOfDevices.
@Test
public void testTridentMinMaxOfDevices() {
Fields fields = new Fields("device-id", "count");
List<Values> content = new ArrayList<Values>();
for (int i = 0; i < SPOUT_BATCH_SIZE; i++) content.add(new Values(i + 1));
ShuffleValuesBatchSpout spout = new ShuffleValuesBatchSpout(fields, content, content);
TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("device-gen-spout", spout).each(fields, new Debug("#### devices"));
stream.minBy("device-id").each(fields, new AssertMinDebug());
stream.maxBy("count").each(fields, new AssertMaxDebug());
Map config = new HashMap();
config.put(Config.TOPOLOGY_NAME, "TridentMinMaxOfDevicesTest");
//the test can pass if the 2 AssertDebug pass throughout the test
JStormUnitTestRunner.submitTopology(tridentTopology.build(), config, 120, null);
}
use of storm.trident.Stream in project storm by nathanmarz.
the class GroupedStream method partitionAggregate.
@Override
public IAggregatableStream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) {
Aggregator groupedAgg = new GroupedAggregator(agg, _groupFields, inputFields, functionFields.size());
Fields allInFields = TridentUtils.fieldsUnion(_groupFields, inputFields);
Fields allOutFields = TridentUtils.fieldsConcat(_groupFields, functionFields);
Stream s = _stream.partitionAggregate(allInFields, groupedAgg, allOutFields);
return new GroupedStream(s, _groupFields);
}
Aggregations