use of com.twitter.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));
}
use of com.twitter.heron.api.tuple.Values in project heron by twitter.
the class HdfsStringSpout method nextTuple.
@Override
public void nextTuple() {
if (br == null) {
return;
}
try {
String line = "";
if ((line = br.readLine()) != null) {
collector.emit(new Values(line));
} else {
br.close();
br = null;
}
} catch (IOException e) {
// Clean stuff if any exceptions
try {
// Close the outmost is enough
br.close();
} catch (IOException e1) {
throw new RuntimeException("Unable to close stream reader", e1);
}
throw new RuntimeException("Unable to emit tuples normally", e);
}
}
use of com.twitter.heron.api.tuple.Values in project heron by twitter.
the class LocalFileSpout method nextTuple.
// We do not explicitly close the buffered reader, even on EoF. This is in case more content is
// added to file, we will read that content as well
@Override
public void nextTuple() {
if (br == null) {
return;
}
try {
String currentLine;
if ((currentLine = br.readLine()) != null) {
collector.emit(new Values(currentLine));
} else {
br.close();
br = null;
}
} catch (IOException e) {
// Clean stuff if any exceptions
try {
// Close the outmost is enough
if (br != null) {
br.close();
}
} catch (IOException e1) {
throw new RuntimeException("Unable to close stream reader", e1);
}
throw new RuntimeException("Unable to emit tuples normally", e);
}
}
use of com.twitter.heron.api.tuple.Values in project incubator-heron by apache.
the class JoinOperatorTest method getTupleWindow.
private TupleWindow getTupleWindow() {
TopologyAPI.StreamId leftComponentStreamId = TopologyAPI.StreamId.newBuilder().setComponentName("leftComponent").setId("s1").build();
TopologyAPI.StreamId rightComponentStreamId = TopologyAPI.StreamId.newBuilder().setComponentName("rightComponent").setId("s1").build();
List<Tuple> tuples = new LinkedList<>();
for (int i = 0; i < 5; i++) {
Tuple tuple;
if (i % 2 == 0) {
tuple = getTuple(leftComponentStreamId, new Fields("a"), new Values(new KeyValue<String, String>("key1", String.valueOf(i))));
} else {
tuple = getTuple(rightComponentStreamId, new Fields("a"), new Values(new KeyValue<String, String>("key1", String.valueOf(i))));
}
tuples.add(tuple);
}
for (int i = 5; i < 8; i++) {
Tuple tuple = getTuple(leftComponentStreamId, new Fields("a"), new Values(new KeyValue<String, String>("key2", String.valueOf(i))));
tuples.add(tuple);
}
for (int i = 8; i < 12; i++) {
Tuple tuple = getTuple(rightComponentStreamId, new Fields("a"), new Values(new KeyValue<String, String>("key3", 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 FilterOperator method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(Tuple tuple) {
R obj = (R) tuple.getValue(0);
if (filterFn.test(obj)) {
collector.emit(new Values(obj));
}
collector.ack(tuple);
}
Aggregations