本文整理匯總了Java中backtype.storm.tuple.Tuple.getIntegerByField方法的典型用法代碼示例。如果您正苦於以下問題:Java Tuple.getIntegerByField方法的具體用法?Java Tuple.getIntegerByField怎麽用?Java Tuple.getIntegerByField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類backtype.storm.tuple.Tuple
的用法示例。
在下文中一共展示了Tuple.getIntegerByField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
String subreddit = tuple.getStringByField("subreddit");
String storyId = tuple.getStringByField("storyid");
String storyURL = tuple.getStringByField("storyurl");
String storyTitle = tuple.getStringByField("storytitle");
String commentId = tuple.getStringByField("commentid");
String comment = tuple.getStringByField("comment");
int sentimentScore = tuple.getIntegerByField("score");
long timestamp = tuple.getLongByField("timestamp");
LOG.info("Received {}:{}:{}:{}:{}:{}:[{}]", subreddit, sentimentScore, storyId, storyURL,
storyTitle, commentId, comment);
collector.ack(tuple);
summary.update(subreddit, storyId, storyURL, storyTitle, commentId,
comment, sentimentScore, timestamp);
// Publish updated statistics only every 30 secs.
long curTime = System.currentTimeMillis();
if (lastPublishedTimestamp == 0 ) {
// Since messages come one by one to Summarizer, publishing immediately on first message
// will show just 1 comment and looks odd. Instead, mark now as last published time
// so that by next publishing window, we'd have received a couple of comments to show meaningful
// rankings.
lastPublishedTimestamp = curTime;
} else if (curTime - lastPublishedTimestamp > 30000) {
LOG.info("Publishing statistics to ZK");
this.publisher.publish(summary);
lastPublishedTimestamp = curTime;
}
}