@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); //Integer count = 30; // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple tuple) { // access the first column 'word' String word = tuple.getStringByField("word"); // access the second column 'count' Integer count = tuple.getIntegerByField("count"); // publish the word count to redis using word as the key redis.publish("WordCountTopology", word + "|" + Long.toString(count)); }
@Override public void execute(Tuple input) { int statusCode = input.getIntegerByField(Field.RESPONSE); int count = 0; if (counts.containsKey(statusCode)) { count = counts.get(statusCode); } count++; counts.put(statusCode, count); collector.emit(input, new Values(statusCode, count)); collector.ack(input); }
private Map<String, Integer> groupByField(List<Tuple> tuples, String field) { Map<String, Integer> counts = new HashMap<>(); for (Tuple tuple : tuples) { if (counts.containsKey(tuple.getStringByField(field))) { counts.put(tuple.getStringByField(field), counts.get(tuple.getStringByField(field)) + 1); } else { counts.put(tuple.getStringByField(field), tuple.getIntegerByField("count")); } collector.ack(tuple); } return counts; }
public void execute(Tuple tuple) { String line = tuple.getStringByField("line"); Integer lineNum = tuple.getIntegerByField("lineNum"); System.out.println("######## CounterBolt.execute: " + lineNum + ". " + line); lineNumSet.add(lineNum); collector.emit(tuple, new Values(lineNum)); collector.ack(tuple); }
@Override protected void finishBatch() { List<Tuple> _tuples = new ArrayList<Tuple>(); queue.drainTo(_tuples); Set<Tuple> tuples = new TreeSet<>(new TuplesOrdering("userFollowersCount")); tuples.addAll(_tuples); tuples = tuples.size() > rankMaxThreshold ? ImmutableSet.copyOf(Iterables.limit(tuples, rankMaxThreshold)) : tuples; for (Tuple tuple : tuples) collector.emit( new Values(tuple.getStringByField("username"), tuple.getIntegerByField("userFollowersCount"))); }
@Override protected void finishBatch() { List<Tuple> _tuples = new ArrayList<Tuple>(); queue.drainTo(_tuples); Set<Tuple> tuples = new TreeSet<>(new TuplesOrdering("followersCount")); tuples.addAll(_tuples); tuples = tuples.size() > rankMaxThreshold ? ImmutableSet.copyOf(Iterables.limit(tuples, rankMaxThreshold)) : tuples; for (Tuple tuple : tuples) { collector.emit(new Values("user_followers", tuple.getStringByField("username"), tuple.getIntegerByField("followersCount"))); collector.ack(tuple); } }
public FlowInfo(Tuple tuple) { flowId = tuple.getStringByField(FLOW_ID); event = (Event) tuple.getValueByField(EVENT); idx = tuple.getIntegerByField(FLOW_OP_IDX); idx++; streamName = tuple.getStringByField(STREAM_NAME); previousStream = tuple.getStringByField(LAST_STREAM); if(tuple.contains(PARTITION)) partition = tuple.getStringByField(PARTITION); }