/** * Emits a new tuple to the default stream anchored on a group of input tuples. The emitted values must be immutable. * * @param anchors the tuples to anchor to * @param tuple the new output tuple from this bolt * @return the list of task ids that this new tuple was sent to */ public List<Integer> emit(Collection<Tuple> anchors, List<Object> tuple) { return emit(Utils.DEFAULT_STREAM_ID, anchors, tuple); }
/** * Emits a new tuple to the default stream anchored on a single tuple. The emitted values must be immutable. * * @param anchor the tuple to anchor to * @param tuple the new output tuple from this bolt * @return the list of task ids that this new tuple was sent to */ public List<Integer> emit(Tuple anchor, List<Object> tuple) { return emit(Utils.DEFAULT_STREAM_ID, anchor, tuple); }
/** * Emits a new unanchored tuple to the default stream. Beacuse it's unanchored, if a failure happens downstream, this new tuple won't * affect whether any spout tuples are considered failed or not. The emitted values must be immutable. * * @param tuple the new output tuple from this bolt * @return the list of task ids that this new tuple was sent to */ public List<Integer> emit(List<Object> tuple) { return emit(Utils.DEFAULT_STREAM_ID, tuple); }
/** * Emits a new tuple to a specific stream with a single anchor. The emitted values must be immutable. * * @param streamId the stream to emit to * @param anchor the tuple to anchor to * @param tuple the new output tuple from this bolt * @return the list of task ids that this new tuple was sent to */ public List<Integer> emit(String streamId, Tuple anchor, List<Object> tuple) { return emit(streamId, Arrays.asList(anchor), tuple); }
private void emit(Map<Object, Long> counts, int actualWindowLengthInSeconds) { for (Entry<Object, Long> entry : counts.entrySet()) { Object obj = entry.getKey(); Long count = entry.getValue(); collector.emit(new Values(obj, count, actualWindowLengthInSeconds)); } }
private void tryEmitAndAck(Collection<Values> values, Tuple tuple) { for (Values value : values) { collector.emit(tuple, value); } collector.ack(tuple); }
public void execute(Tuple input) { String word = (String) input.getValues().get(0); int count = (Integer) input.getValues().get(1); _counts.put(word, count); int globalCount = 0; for (String w : _counts.keySet()) { globalCount += _counts.get(w); } _collector.emit(tuple(globalCount)); _collector.ack(input); }
@Override public void execute(Tuple tuple) { collector.emit(tuple, tuple.getValues()); collector.ack(tuple); }
public void execute(Tuple input) { _count++; _collector.emit(input, new Values(_count)); _collector.ack(input); }
/** * Forwards the checkpoint tuple downstream. * * @param checkpointTuple the checkpoint tuple * @param action the action (prepare, commit, rollback or initstate) * @param txid the transaction id. */ protected void handleCheckpoint(Tuple checkpointTuple, Action action, long txid) { collector.emit(CHECKPOINT_STREAM_ID, checkpointTuple, new Values(txid, action)); collector.ack(checkpointTuple); }
public void execute(Tuple input) { Integer sourceId = input.getInteger(0); Long eventId = input.getLong(1); Long recentEvent = recentEventId.get(sourceId); if (null != recentEvent && eventId <= recentEvent) { String error = "Error: event id is not in strict order! event source Id: " + sourceId + ", last event Id: " + recentEvent + ", current event Id: " + eventId; _collector.emit(input, new Values(error)); } recentEventId.put(sourceId, eventId); _collector.ack(input); }
private void emitTuples(Tuple input) { for (OutputStreamEngine se: outputStreams) { // we may output many tuples for a given input tuple while (se.shouldEmit() != null) { collector.emit(se.streamName, input, new Values(se.nextKey(), "SOME-BOLT-VALUE")); } } }
@Override public void execute(Tuple tuple) { _collector.emit(tuple, new Values(tuple.getString(0) + "!!!")); _collector.ack(tuple); }
@Override public void execute(Tuple input) { seen.add(input); if (seen.size() == branches) { collector.emit(seen, new Values(1)); seen.forEach(t -> collector.ack(t)); seen.clear(); } } }
@Override public void execute(Tuple input) { ArrayList<Tuple> anchors = new ArrayList<>(); anchors.add(input); anchors.add(input); collector.emit(anchors, new Values(1)); collector.ack(input); } }
@Override public void execute(TupleWindow inputWindow) { for (Tuple tuple : inputWindow.get()) { sum += tuple.getIntegerByField("value"); } state.put("sum", sum); collector.emit(new Values(sum)); }
@Override public void execute(Tuple input) { IntStream.range(0, branches) .forEach(i -> collector.emit(input, new Values(i))); collector.ack(input); } }
@Override public void execute(Tuple tuple) { String word = tuple.getString(0); Long count = wordCounts.get(word, 0L); count++; wordCounts.put(word, count); collector.emit(tuple, new Values(word, count)); collector.ack(tuple); }
@Override public void execute(Tuple tuple) { String orig = tuple.getString(0); String ret = getFromCache(orig); if (ret == null) { ret = orig + "!!!"; addToCache(orig, ret); } _collector.emit(tuple, new Values(ret)); _collector.ack(tuple); }
@Override public void execute(Tuple input) { collector.emit(new Values(emitted, acked, failed, executed)); if (acked - failed == 0) { collector.ack(input); } else { collector.fail(input); } } }