use of com.twitter.heron.api.tuple.Values in project incubator-heron by apache.
the class TestWordSpout method nextTuple.
public void nextTuple() {
final String word = words[rand.nextInt(words.length)];
collector.emit(new Values(word));
if (!throttleDuration.isZero()) {
// sleep to throttle back cpu usage
SysUtils.sleep(throttleDuration);
}
}
use of com.twitter.heron.api.tuple.Values in project incubator-heron by apache.
the class CustomSpout method nextTuple.
@Override
public void nextTuple() {
CustomObject obj = inputObjects[(emitted++) % inputObjects.length];
collector.emit(new Values(obj));
}
use of com.twitter.heron.api.tuple.Values in project incubator-heron by apache.
the class ReduceByKeyAndWindowOperatorTest method getTupleWindow.
private TupleWindow getTupleWindow(int nkeys, int count) {
TopologyAPI.StreamId componentStreamId = TopologyAPI.StreamId.newBuilder().setComponentName("sourceComponent").setId("default").build();
List<Tuple> tuples = new LinkedList<>();
for (int i = 0; i < nkeys; i++) {
for (int j = 0; j < count; ++j) {
Tuple tuple = getTuple(componentStreamId, new Fields("a"), new Values(String.valueOf(i)));
tuples.add(tuple);
}
}
TupleWindow tupleWindow = new TupleWindowImpl(tuples, new LinkedList<>(), new LinkedList<>(), startTime, endTime);
return tupleWindow;
}
use of com.twitter.heron.api.tuple.Values in project incubator-heron by apache.
the class UnionOperator method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(Tuple tuple) {
I obj = (I) tuple.getValue(0);
collector.emit(new Values(obj));
collector.ack(tuple);
}
use of com.twitter.heron.api.tuple.Values in project streaming-samples by ashvina.
the class SplitSentence method execute.
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
restriction.execute();
String sentence = tuple.getStringByField(WordCountTopologyHelper.FIELD_SENTENCE);
String[] words = sentence.split(" ");
for (String word : words) {
if (word.trim().isEmpty()) {
continue;
}
collector.emit(new Values(word));
}
}
Aggregations