String str = (input.getStringByField("CONTROL")); LOG.warn(str); return;
@Override public String getKeyFromTuple(Tuple tuple) { String key = tuple.getStringByField(Constants.FIELD_ERROR_KEY); return key; }
private String getKey(Tuple tuple) { return tuple.getStringByField(Field.HOUSE_ID) + ':' + tuple.getStringByField(Field.HOUSEHOLD_ID) + ':' + tuple.getStringByField(Field.PLUG_ID); }
@Override protected String getKey(Tuple tuple) { return tuple.getStringByField(Field.HOUSE_ID) + ":" + tuple.getStringByField(Field.HOUSEHOLD_ID) + ":" + tuple.getStringByField(Field.PLUG_ID); }
@Override public String mapToType(Tuple tuple) { return tuple.getStringByField("type"); }
@Override public String mapToId(Tuple tuple) { return tuple.getStringByField("id"); }
@Override public String getMessageFromTuple(Tuple tuple) { return tuple.getStringByField(Constants.FIELD_ERROR_VALUE); }
public static 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 { if (tuple.getStringByField(field) != null) counts.put(tuple.getStringByField(field), 1); } } return counts; }
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); }
@Override public void execute(Tuple input) { pr.println(input.getStringByField(field)); pr.flush(); collector.ack(input); }
@Override public String format(Tuple tuple) { String eventID = tuple.getStringByField(Field.EVENT_ID); String[] actions = (String[]) tuple.getValueByField(Field.ACTIONS); String actionList = actions.length > 1 ? StringUtils.join(actions) : actions[0]; return eventID + "," + actionList; }
@Override public void execute(Tuple input) { pr.println(input.getStringByField(field)); pr.flush(); collector.ack(input); }
@Override public void execute(Tuple tuple) { long start = System.currentTimeMillis(); JSONObject objectToJoin = new JSONObject(tuple.getStringByField(joinObjectField)); String[] mergePath = this.mergePath.split(","); joinJSONObject(objectToJoin, mergePath, 0); outputCollector.emit(new Values(objectToJoin.getString(atId), objectToJoin.toString())); outputCollector.ack(tuple); LOG.debug("id: "+ tuple.getStringByField("id") + " " + (System.currentTimeMillis() - start)); }
@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 input) { String word = input.getStringByField(Field.WORD); MutableLong count = counts.get(word); if (count == null) { count = new MutableLong(0); counts.put(word, count); } count.increment(); collector.emit(input, new Values(word, count.get())); collector.ack(input); }
@Override public void execute(Tuple input) { String deviceID = input.getStringByField(Field.DEVICE_ID); double movingAverageInstant = input.getDoubleByField(Field.MOVING_AVG); double nextDouble = input.getDoubleByField(Field.VALUE); if (Math.abs(nextDouble - movingAverageInstant) > spikeThreshold * movingAverageInstant) { collector.emit(input, new Values(deviceID, movingAverageInstant, nextDouble, "spike detected")); } collector.ack(input); }
@Override public void execute(Tuple input) { String deviceID = input.getStringByField(Field.DEVICE_ID); double nextDouble = input.getDoubleByField(Field.VALUE); double movingAvergeInstant = movingAverage(deviceID, nextDouble); collector.emit(input, new Values(deviceID, movingAvergeInstant, nextDouble)); collector.ack(input); }