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


Java Tuple.getLong方法代碼示例

本文整理匯總了Java中backtype.storm.tuple.Tuple.getLong方法的典型用法代碼示例。如果您正苦於以下問題:Java Tuple.getLong方法的具體用法?Java Tuple.getLong怎麽用?Java Tuple.getLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在backtype.storm.tuple.Tuple的用法示例。


在下文中一共展示了Tuple.getLong方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector collector) {
    LOGGER.debug("Calculating positive score");

    Long id     = input.getLong(input.fieldIndex("tweet_id"));
    String text = input.getString(input.fieldIndex("tweet_text"));

    Set<String> posWords = PositiveWords.getWords();
    String[] words = text.split(" ");

    int numWords = words.length;
    int numPosWords = 0;

    for (String word : words) {
        if (posWords.contains(word))
            numPosWords++;
    }

    collector.emit(new Values(id, (float) numPosWords / numWords, text));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:20,代碼來源:PositiveSentimentBolt.java

示例2: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector collector) {
    Long id      = input.getLong(input.fieldIndex("tweet_id"));
    String tweet = input.getString(input.fieldIndex("tweet_text"));
    Float pos    = input.getFloat(input.fieldIndex("pos_score"));
    Float neg    = input.getFloat(input.fieldIndex("neg_score"));
    String score = input.getString(input.fieldIndex("score"));

    HttpPost post = new HttpPost(this.webserver);
    String content = String.format(
        "{\"id\": \"%d\", "  +
        "\"text\": \"%s\", " +
        "\"pos\": \"%f\", "  +
        "\"neg\": \"%f\", "  +
        "\"score\": \"%s\" }",
        id, tweet, pos, neg, score);

    try {
        post.setEntity(new StringEntity(content));
        HttpResponse response = client.execute(post);
        org.apache.http.util.EntityUtils.consume(response.getEntity());
    } catch (Exception ex) {
        LOGGER.error("exception thrown while attempting post", ex);
        LOGGER.trace(null, ex);
        reconnect();
    }
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:27,代碼來源:NodeNotifierBolt.java

示例3: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector collector) {
    LOGGER.debug("Calculating negitive score");

    Long id     = input.getLong(input.fieldIndex("tweet_id"));
    String text = input.getString(input.fieldIndex("tweet_text"));

    Set<String> negWords = NegativeWords.getWords();
    String[] words = text.split(" ");

    int numWords = words.length;
    int numNegWords = 0;
    for (String word : words) {
        if (negWords.contains(word))
            numNegWords++;
    }

    collector.emit(new Values(id, (float) numNegWords / numWords, text));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:19,代碼來源:NegativeSentimentBolt.java

示例4: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple, BasicOutputCollector collector) {
    LOGGER.debug("Scoring tweet");

    Long id     = tuple.getLong(tuple.fieldIndex("tweet_id"));
    String text = tuple.getString(tuple.fieldIndex("tweet_text"));
    Float pos   = tuple.getFloat(tuple.fieldIndex("pos_score"));
    Float neg   = tuple.getFloat(tuple.fieldIndex("neg_score"));

    String score = pos > neg ? "positive" : "negative";

    LOGGER.debug(String.format("tweet %s: %s", id, score));
    collector.emit(new Values(id, text, pos, neg, score));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:14,代碼來源:SentimentScoringBolt.java

示例5: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector collector) {
    LOGGER.debug("removing stop words");

    Long id     = input.getLong(input.fieldIndex("tweet_id"));
    String text = input.getString(input.fieldIndex("tweet_text"));

    List<String> stopWords = StopWords.getWords();

    for (String word : stopWords) {
        text = text.replaceAll("\\b" + word + "\\b", "");
    }

    collector.emit(new Values(id, text));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:15,代碼來源:StemmingBolt.java

示例6: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void execute(Tuple arg0) {
  boolean isOdd = false;
  double waittime = Math.random();
  if (waittime < 999) {
    waittime = waittime + 1000;

  } else {
    waittime = (waittime % 1000) + 1500;

  }
  if (!((waittime % 2) > 0.5))
    isOdd = true;
  try {

    // long startTime = System.currentTimeMillis();
    /*
     * while(System.currentTimeMillis()- startTime <=waittime){ Thread.sleep(10); }
     */
    Thread.sleep(1000);
    FileWriter fileWriter = new FileWriter("C:/0-DRIVE/Apps/storm-local/OutPut.txt", true);

    long boltTime = System.currentTimeMillis();
    Long timeInTransit = boltTime - arg0.getLong(0);
    BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
    bufferedWriter.write(timeInTransit.toString());
    bufferedWriter.newLine();
    bufferedWriter.close();
    if (!isOdd) {
      _collector.emit("oddstream", new Values(arg0));
    } else {
      _collector.emit("evenstream", new Values(arg0));
    }
    /*
     * String str ="str"; str.charAt(4);
     */
    _collector.ack(arg0);
  } catch (Throwable e) {
    e.printStackTrace();
    // _collector.fail(arg0);

  }

}
 
開發者ID:techysoul,項目名稱:java,代碼行數:45,代碼來源:DeliveryCheckBolt.java

示例7: execute

import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector collector) {
    LOGGER.debug("removing ugly characters");

    Long id     = input.getLong(input.fieldIndex("tweet_id"));
    String text = input.getString(input.fieldIndex("tweet_text"));

    text = text.replaceAll("[^a-zA-Z\\s]", "").trim().toLowerCase();

    collector.emit(new Values(id, text));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:11,代碼來源:TextFilterBolt.java


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