Search in sources :

Example 16 with Values

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

the class ABSpout method nextTuple.

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

Example 17 with Values

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

the class TestFibonacciSpout method nextTuple.

@Override
public void nextTuple() {
    Utils.sleep(100);
    final int[] words = new int[] { 0, 1, 2, 3, 5, 8, 13, 21, 34 };
    final Random rand = new Random();
    final int number = words[rand.nextInt(words.length)];
    final String property = holder.getProperty();
    final int numberProperty = holder.getNumberProperty();
    final String publicProperty = holder.publicProperty;
    LOG.info("Constructor Args: " + property);
    LOG.info("Property set by setter: " + numberProperty);
    LOG.info("Property set by public field: " + publicProperty);
    LOG.info("Emitting: number " + number);
    collector.emit(new Values(number));
}
Also used : Random(java.util.Random) Values(org.apache.heron.api.tuple.Values)

Example 18 with Values

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

the class StatefulNumberSpout method nextTuple.

@Override
public void nextTuple() {
    Utils.sleep(1000);
    long val = msgId;
    long randomNumber = System.currentTimeMillis() - (24 * 60 * 60 * 1000);
    System.out.println("Emitting: " + val);
    collector.emit(new Values(val, randomNumber, msgId), msgId);
    msgId++;
}
Also used : Values(org.apache.heron.api.tuple.Values)

Example 19 with Values

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

the class StatefulWindowSumBolt method execute.

@Override
public void execute(TupleWindow inputWindow) {
    for (Tuple tuple : inputWindow.get()) {
        System.out.println("Adding to sum: " + tuple.getLongByField("value"));
        sum += tuple.getLongByField("value");
        System.out.println("Sum is now: " + sum);
    }
    collector.emit(new Values(sum));
}
Also used : Values(org.apache.heron.api.tuple.Values) Tuple(org.apache.heron.api.tuple.Tuple)

Example 20 with Values

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

the class EmitDirectRoundRobinBolt method execute.

@Override
public void execute(Tuple tuple) {
    String word = toSend[emitted % toSend.length];
    outputCollector.emitDirect(emitted, new Values(word));
}
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