Java Code Examples for storm.trident.tuple.TridentTuple#getString()
The following examples show how to use
storm.trident.tuple.TridentTuple#getString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScoreUpdater.java From storm-example with Apache License 2.0 | 6 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { Board board = (Board) tuple.get(0); int score = tuple.getInteger(1); String player = tuple.getString(2); String key = board.toKey(); LOG.debug("Got (" + board.toKey() + ") => [" + score + "] for [" + player + "]"); // Always compute things from X's perspective // We'll flip things when we interpret it if it is O's turn. synchronized (MUTEX) { Integer currentScore = scores.get(key); if (currentScore == null || (player.equals("X") && score > currentScore)) { updateScore(board, score); } else if (player.equals("O") && score > currentScore) { updateScore(board, score); } } }
Example 2
Source File: TridentWordCount.java From flink-perf with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 3
Source File: TuplifyArgs.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple input, TridentCollector collector) { String args = input.getString(0); List<List<Object>> tuples = (List) JSONValue.parse(args); for(List<Object> tuple: tuples) { collector.emit(tuple); } }
Example 4
Source File: ReturnResultsReducer.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(ReturnResultsState state, int streamIndex, TridentTuple input, TridentCollector collector) { if (streamIndex == 0) { state.returnInfo = input.getString(0); } else { state.results.add(input); } }
Example 5
Source File: TridentTopologySource.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 6
Source File: TridentWordCountTest.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 7
Source File: TridentFastWordCount.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 8
Source File: TridentWordCount.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 9
Source File: Split.java From trident-tutorial with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { if(splitter==null){ splitter = Splitter.on(on); } String string = tuple.getString(0); for (String spilt : splitter.split(string)) { collector.emit(new Values(spilt)); } }
Example 10
Source File: StringCounter.java From trident-tutorial with Apache License 2.0 | 5 votes |
@Override public void aggregate(Map<String, Integer> val, TridentTuple tuple, TridentCollector collector) { String loc = tuple.getString(0); Integer previousValue = val.get(loc); previousValue = previousValue == null ? 0 : previousValue; val.put(loc, previousValue + 1); }
Example 11
Source File: TridentTopologySource.java From flux with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); for (String word : sentence.split(" ")) { collector.emit(new Values(word)); } }
Example 12
Source File: PageView.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String pvString = tuple.getString(0); PageView pageView = PageView.fromString(pvString); if (null == pageView) { LOG.error("invalid pageview string '" + pvString + "'"); return; } List<Object> values = new ArrayList<Object>(); for (Item field : fields) { values.add(pageView.getValue(field)); } collector.emit(values); }
Example 13
Source File: WordSplit.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); LOG.debug("receive sentence: '" + sentence + "'"); if (sentence != null) { for (String word : splitSentence(sentence)) { collector.emit(new Values(word)); } } }
Example 14
Source File: ArgsFunction.java From storm-example with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String args = tuple.getString(0); Log.info("Executing DRPC w/ args = [" + args + "]"); Board board = new Board(args); GameState gameState = new GameState(board, new ArrayList<Board>(), "X"); Log.info("Emitting [" + gameState + "]"); List<Object> values = new ArrayList<Object>(); values.add(gameState); collector.emit(values); }
Example 15
Source File: TickParser.java From hadoop-arch-book with Apache License 2.0 | 5 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String tick = tuple.getString(0); String[] parts = tick.split(","); System.out.println("TickParser: price=" + Double.valueOf(parts[4])); collector.emit(new Values(Double.valueOf(parts[4]))); }
Example 16
Source File: RegexFilter.java From trident-tutorial with Apache License 2.0 | 4 votes |
@Override public boolean isKeep(TridentTuple tuple) { String string = tuple.getString(0); return pattern.matcher(string).matches(); }
Example 17
Source File: SalesMapper.java From storm-cassandra-cql with Apache License 2.0 | 4 votes |
@Override public String getKey(TridentTuple tuple) { String state = tuple.getString(1); return state; }
Example 18
Source File: DocumentBuilder.java From storm-trident-elasticsearch with Apache License 2.0 | 4 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); collector.emit(new Values( new Document<>("my_index", "my_type", sentence, String.valueOf(sentence.hashCode())))); }
Example 19
Source File: IndexMapStateTest.java From storm-trident-elasticsearch with Apache License 2.0 | 4 votes |
@Override public void execute(TridentTuple tuple, TridentCollector collector) { String sentence = tuple.getString(0); collector.emit(new Values( new Document<>("my_index", "my_type", sentence, String.valueOf(sentence.hashCode())))); }