Search in sources :

Example 26 with Values

use of org.apache.heron.api.tuple.Values in project heron by twitter.

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(org.apache.heron.api.tuple.Values)

Example 27 with Values

use of org.apache.heron.api.tuple.Values in project heron by twitter.

the class RandomIntegerSpout method nextTuple.

@Override
public void nextTuple() {
    Utils.sleep(100);
    collector.emit(new Values(rand.nextInt(1000), System.currentTimeMillis() - (24 * 60 * 60 * 1000), ++msgId), msgId);
}
Also used : Values(org.apache.heron.api.tuple.Values)

Example 28 with Values

use of org.apache.heron.api.tuple.Values in project heron by twitter.

the class StatefulABSpout method nextTuple.

@Override
public void nextTuple() {
    String word = TO_SEND[emitted % TO_SEND.length];
    if (appendSequenceId) {
        word = word + "_" + emitted;
    }
    collector.emit(new Values(word));
    if (!state.containsKey(word)) {
        state.put(word, 1);
    } else {
        state.put(word, state.get(word) + 1);
    }
    emitted++;
}
Also used : Values(org.apache.heron.api.tuple.Values)

Example 29 with Values

use of org.apache.heron.api.tuple.Values in project heron by twitter.

the class CustomSpout method nextTuple.

@Override
public void nextTuple() {
    CustomObject obj = inputObjects[(emitted++) % inputObjects.length];
    collector.emit(new Values(obj));
}
Also used : Values(org.apache.heron.api.tuple.Values)

Example 30 with Values

use of org.apache.heron.api.tuple.Values in project heron by twitter.

the class TestSpout method nextTuple.

@Override
public void nextTuple() {
    // It will emit A, B, A, B, A, B, A, B, A, B
    if (emitted < EMIT_COUNT) {
        String word = toSend[emitted % toSend.length];
        emit(outputCollector, new Values(word), MESSAGE_ID, emitted++);
    }
}
Also used : Values(org.apache.heron.api.tuple.Values)

Aggregations

Values (org.apache.heron.api.tuple.Values)37 Tuple (org.apache.heron.api.tuple.Tuple)8 KeyValue (org.apache.heron.streamlet.KeyValue)7 TupleWindow (org.apache.heron.api.windowing.TupleWindow)6 Fields (org.apache.heron.api.tuple.Fields)5 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 TopologyAPI (org.apache.heron.api.generated.TopologyAPI)3 TupleWindowImpl (org.apache.heron.api.windowing.TupleWindowImpl)3 KeyedWindow (org.apache.heron.streamlet.KeyedWindow)2 Window (org.apache.heron.streamlet.Window)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Random (java.util.Random)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 TopologyContext (org.apache.heron.api.topology.TopologyContext)1 SerializablePredicate (org.apache.heron.streamlet.SerializablePredicate)1