當前位置: 首頁>>代碼示例>>Java>>正文


Java Tuple.getIntegerByField方法代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:pathbreak,項目名稱:reddit-sentiment-storm,代碼行數:35,代碼來源:SummarizerBolt.java


注:本文中的backtype.storm.tuple.Tuple.getIntegerByField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。