Search in sources :

Example 11 with Values

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);
    }
}
Also used : Values(com.twitter.heron.api.tuple.Values)

Example 12 with Values

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));
}
Also used : Values(com.twitter.heron.api.tuple.Values)

Example 13 with Values

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;
}
Also used : Fields(com.twitter.heron.api.tuple.Fields) TupleWindowImpl(com.twitter.heron.api.windowing.TupleWindowImpl) Values(com.twitter.heron.api.tuple.Values) TupleWindow(com.twitter.heron.api.windowing.TupleWindow) Tuple(com.twitter.heron.api.tuple.Tuple) LinkedList(java.util.LinkedList) TopologyAPI(com.twitter.heron.api.generated.TopologyAPI)

Example 14 with Values

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);
}
Also used : Values(com.twitter.heron.api.tuple.Values)

Example 15 with Values

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));
    }
}
Also used : Values(com.twitter.heron.api.tuple.Values)

Aggregations

Values (com.twitter.heron.api.tuple.Values)34 Tuple (com.twitter.heron.api.tuple.Tuple)7 TupleWindow (com.twitter.heron.api.windowing.TupleWindow)6 IOException (java.io.IOException)6 Fields (com.twitter.heron.api.tuple.Fields)5 KeyValue (com.twitter.heron.streamlet.KeyValue)4 TopologyAPI (com.twitter.heron.api.generated.TopologyAPI)3 TupleWindowImpl (com.twitter.heron.api.windowing.TupleWindowImpl)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 KeyedWindow (com.twitter.heron.streamlet.KeyedWindow)2 Window (com.twitter.heron.streamlet.Window)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2 TweetsGenerator (com.github.ashvina.common.TweetsGenerator)1 TopologyContext (com.twitter.heron.api.topology.TopologyContext)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 RankableObjectWithFields (org.apache.storm.starter.tools.RankableObjectWithFields)1