use of org.apache.storm.tuple.Fields in project storm by apache.
the class TridentTopologySource method getTopology.
public StormTopology getTopology(Config config) {
this.spout = new FixedBatchSpout(new Fields("sentence"), 20, new Values("one two"), new Values("two three"), new Values("three four"), new Values("four five"), new Values("five six"));
TridentTopology trident = new TridentTopology();
trident.newStream("wordcount", spout).name("sentence").parallelismHint(1).shuffle().each(new Fields("sentence"), new Split(), new Fields("word")).parallelismHint(1).groupBy(new Fields("word")).persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")).parallelismHint(1);
return trident.build();
}
use of org.apache.storm.tuple.Fields in project storm by apache.
the class Murmur3StreamGrouping method prepare.
/**
* {@inheritDoc}
*/
@Override
public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks) {
this.targetTasks = targetTasks;
this.partitionKeyIndexes = new ArrayList<>();
Fields componentOutputFields = context.getComponentOutputFields(stream);
for (String partitionKeyName : partitionKeyNames) {
partitionKeyIndexes.add(componentOutputFields.fieldIndex(partitionKeyName));
}
}
use of org.apache.storm.tuple.Fields in project storm by apache.
the class OpaqueTridentEventCount method buildTopology.
@Override
protected StormTopology buildTopology(EventHubSpout eventHubSpout) {
TridentTopology topology = new TridentTopology();
OpaqueTridentEventHubSpout spout = new OpaqueTridentEventHubSpout(spoutConfig);
TridentState state = topology.newStream("stream-" + spoutConfig.getTopologyName(), spout).parallelismHint(spoutConfig.getPartitionCount()).aggregate(new Count(), new Fields("partial-count")).persistentAggregate(new MemoryMapState.Factory(), new Fields("partial-count"), new Sum(), new Fields("count"));
state.newValuesStream().each(new Fields("count"), new LoggingFilter("got count: ", 10000));
return topology.build();
}
use of org.apache.storm.tuple.Fields in project storm by apache.
the class EsLookupBoltTest method fieldsAreDeclaredThroughProvidedOutput.
@Test
public void fieldsAreDeclaredThroughProvidedOutput() throws Exception {
Fields fields = new Fields(UUID.randomUUID().toString());
when(output.fields()).thenReturn(fields);
OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
bolt.declareOutputFields(declarer);
ArgumentCaptor<Fields> declaredFields = ArgumentCaptor.forClass(Fields.class);
verify(declarer).declare(declaredFields.capture());
assertThat(declaredFields.getValue(), is(fields));
}
use of org.apache.storm.tuple.Fields in project storm by apache.
the class AvroGenericRecordBoltTest method generateTestTuple.
private static Tuple generateTestTuple(GenericRecord record) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("record");
}
};
return new TupleImpl(topologyContext, new Values(record), 1, "");
}
Aggregations