本文整理了Java中backtype.storm.tuple.Tuple.getValue()
方法的一些代码示例,展示了Tuple.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.getValue()
方法的具体详情如下:
包路径:backtype.storm.tuple.Tuple
类名称:Tuple
方法名:getValue
[英]Gets the field at position i in the tuple. Returns object since tuples are dynamically typed.
[中]获取元组中位置i处的字段。返回对象,因为元组是动态类型的。
代码示例来源:origin: alibaba/jstorm
private void registerMetrics(Tuple input) {
synchronized (metricNames) {
metricNames.get().addAll((Set<String>) input.getValue(0));
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input) {
_metricsConsumer.handleDataPoints((IMetricsConsumer.TaskInfo) input.getValue(0), (Collection) input.getValue(1));
_collector.ack(input);
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input) {
Object value = input.getValue(0);
if (input.getSourceStreamId().equals(TopologyMaster.USER_DEFINED_STREAM)) {
TMUdfMessage message = (TMUdfMessage) value;
LOG.info("Received TM UDF message trigged by task-{}", message.spoutTaskId);
} else {
LOG.info("Received unkown message: {}", input);
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
int curr = Utils.get(_counts, key, 0);
_counts.put(key, curr + 1);
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple) {
Object key = tuple.getValue(1);
Number curr = Utils.get(_sums, key, 0);
_sums.put(key, Numbers.add(curr, tuple.getValue(2)));
}
代码示例来源:origin: alibaba/jstorm
@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));
}
}
代码示例来源:origin: alibaba/jstorm
public void fail(Tuple tuple) {
Object id = tuple.getValue(0);
synchronized (_tracked) {
TrackingInfo track = _tracked.get(id);
if (track != null)
track.failed = true;
}
checkFinishId(tuple, TupleType.REGULAR);
_delegate.fail(tuple);
}
代码示例来源:origin: alibaba/jstorm
private void countObjAndAck(Tuple tuple) {
Object obj = tuple.getValue(0);
counter.incrementCount(obj);
collector.ack(tuple);
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple, IKvState<String, Integer> state, TimeWindow window) {
String word = (String) tuple.getValue(0);
Integer count = state.get(word);
if (count == null)
count = 0;
state.put(word, ++count);
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
BatchId id = (BatchId) input.getValue(0);
Long value = input.getLong(1);
AtomicLong counter = counters.get(id);
if (counter == null) {
counter = new AtomicLong(0);
counters.put(id, counter);
}
counter.addAndGet(value);
}
代码示例来源:origin: alibaba/jstorm
@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));
}
}
}
代码示例来源:origin: alibaba/jstorm
public void handlePostCommit(Tuple tuple) {
basicCollector.setContext(tuple);
try {
BatchId id = (BatchId) tuple.getValue(0);
((IPostCommit) delegate).postCommit(id, basicCollector);
} catch (Exception e) {
LOG.info("Failed to do postCommit,", e);
}
collector.ack(tuple);
}
代码示例来源:origin: alibaba/jstorm
@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));
}
}
}
代码示例来源:origin: alibaba/jstorm
@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));
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input) {
Object id = input.getValue(0);
IBatchBolt bolt = getBatchBolt(id);
try {
bolt.execute(input);
_collector.ack(input);
} catch (FailedException e) {
LOG.error("Failed to process tuple in batch", e);
_collector.fail(input);
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
String arg = tuple.getString(0);
Object retInfo = tuple.getValue(1);
collector.emit(new Values(arg + "!!!", retInfo));
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
String input = tuple.getString(1);
collector.emit(new Values(tuple.getValue(0), input + "!"));
}
代码示例来源:origin: alibaba/jstorm
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));
}
代码示例来源:origin: alibaba/jstorm
public void handleCommit(Tuple tuple) {
Object id = tuple.getValue(0);
try {
byte[] commitResult = ((ICommitter) delegate).commit((BatchId) id);
collector.ack(tuple);
updateToZk(id, commitResult);
commited.put(id, commitResult);
} catch (Exception e) {
LOG.error("Failed to commit ", e);
collector.fail(tuple);
}
}
代码示例来源:origin: alibaba/jstorm
@Override
void updateRankingsWithTuple(Tuple tuple) {
Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0);
super.getRankings().updateWith(rankingsToBeMerged);
super.getRankings().pruneZeroCounts();
}
内容来源于网络,如有侵权,请联系作者删除!