public List<Integer> emit(List<Object> tuple) { return emit(Utils.DEFAULT_STREAM_ID, tuple); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { collector.emit(input.getValues()); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = (String) input.getValues().get(0); int count = 0; if (_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String word = tuple.getString(0); Integer count = counts.get(word); if (count == null) count = 0; count++; counts.put(word, count); collector.emit(new Values(word, count)); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { long id = Utils.secureRandomLong(); List<Object> toEmit = new ArrayList<>(); toEmit.add(id); toEmit.addAll(input.getValues()); collector.emit(toEmit); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String args = tuple.getString(0); String returnInfo = tuple.getString(1); long requestId = rand.nextLong(); collector.emit(ARGS_STREAM, new Values(requestId, args)); collector.emit(RETURN_STREAM, new Values(requestId, returnInfo)); collector.emit(ID_STREAM, new Values(requestId)); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { Object id = input.getValue(0); String word = input.getString(1); for (int i = 0; i < word.length(); i++) { if (word.charAt(i) == 'a') { collector.emit("multi", new Values(id, word.substring(0, i))); } } collector.emit("single", new Values(id, word)); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { BatchId batchId = (BatchId) input.getValue(0); for (int i = 0; i < batchSize; i++) { long value = rand.nextInt(10); collector.emit(new Values(batchId, value)); } }
@Override public void execute(Tuple input, BasicOutputCollector collector) { String name = input.getString(0); collector.emit(new Values(name, _conf.get(name))); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String args = tuple.getString(0); String returnInfo = tuple.getString(1); long requestId = rand.nextLong(); collector.emit(ARGS_STREAM, new Values(requestId, args)); collector.emit(RETURN_STREAM, new Values(requestId, returnInfo)); collector.emit(ID_STREAM, new Values(requestId)); }
@Override public void execute(Tuple input, BasicOutputCollector collector) { String name = input.getString(0); collector.emit(new Values(name, _conf.get(name))); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { Object id = tuple.getValue(0); String url = tuple.getString(1); List<String> tweeters = TWEETERS_DB.get(url); if (tweeters != null) { for (String tweeter : tweeters) { collector.emit(new Values(id, tweeter)); } } }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { Object id = tuple.getValue(0); String tweeter = tuple.getString(1); List<String> followers = FOLLOWERS_DB.get(tweeter); if (followers != null) { for (String follower : followers) { collector.emit(new Values(id, follower)); } } }
@Override public void execute(Tuple input, BasicOutputCollector collector) { collector.emit(new Values(input.getValue(0), input.getString(1).length())); }
private void emitRankings(BasicOutputCollector collector) { collector.emit(new Values(rankings.copy())); getLogger().debug("Rankings: " + rankings); }
public void execute(Tuple tuple, BasicOutputCollector collector) { tpsCounter.count(); Long tupleId = tuple.getLong(0); Object obj = tuple.getValue(1); if (obj instanceof TradeCustomer) { TradeCustomer tradeCustomer = (TradeCustomer) obj; Pair trade = tradeCustomer.getTrade(); Pair customer = tradeCustomer.getCustomer(); collector.emit(SequenceTopologyDef.TRADE_STREAM_ID, new Values(tupleId, trade)); collector.emit(SequenceTopologyDef.CUSTOMER_STREAM_ID, new Values(tupleId, customer)); } else if (obj != null) { LOG.info("Unknow type " + obj.getClass().getName()); } else { LOG.info("Nullpointer "); } }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String arg = tuple.getString(0); Object retInfo = tuple.getValue(1); collector.emit(new Values(arg + "!!!", retInfo)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { String input = tuple.getString(1); collector.emit(new Values(tuple.getValue(0), input + "!")); }
public void execute(Tuple tuple, BasicOutputCollector collector) { tpsCounter.count(); Long tupleId = tuple.getLong(0); Pair pair = (Pair) tuple.getValue(1); sum.addAndGet(pair.getValue()); collector.emit(new Values(tupleId, pair)); }
@Override public void execute(Tuple tuple, BasicOutputCollector collector) { TransactionAttempt attempt = (TransactionAttempt) tuple.getValue(0); if (tuple.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) { _state.cleanupBefore(attempt.getTransactionId()); _coord.success(attempt.getTransactionId()); } else { long txid = attempt.getTransactionId(); Object prevMeta = _state.getPreviousState(txid); Object meta = _coord.initializeTransaction(txid, prevMeta, _state.getState(txid)); _state.overrideState(txid, meta); collector.emit(MasterBatchCoordinator.BATCH_STREAM_ID, new Values(attempt, meta)); } }