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


Java TridentTuple.getString方法代碼示例

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


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

示例1: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
/**
 * <p>This function converts a JSON events to JAVA Map.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String jsonEvent = tuple.getString(0);
    if (jsonEvent != null && jsonEvent.length() > 0) {
        Map<String, Object> event = null;
        try {
            event = _mapper.readValue(jsonEvent, Map.class);
            _metric.incrEvent();
        } catch (IOException | NullPointerException ex) {
            Logger.getLogger(MapperFunction.class.getName()).log(Level.SEVERE, "Failed converting a JSON tuple to a Map class [ " + _metricName + " ] \n"
                    + " JSON tuple: " + jsonEvent, ex);
        }
        if (event != null)
            collector.emit(new Values(event));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:20,代碼來源:MapperFunction.java

示例2: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String currentValue;
    int newHashModValue;
    String newValue;
    int currentTry;

    currentTry = 0;
    currentValue = tuple.getString(0);
    newHashModValue = (currentValue.hashCode() % this.numPartitions) + 1;
    newHashModValue = newHashModValue % this.numPartitions;  // rotate back to 0 if necessary

    do {
        newValue = UUID.randomUUID().toString();

        if (currentTry++ >= maxTry) {
            throw new RuntimeException("Couldn't find a value for hash/mod " + newHashModValue +
                    " in " + maxTry + " attempts. Current value is " + newValue +
                    " Number of partitions: " + this.numPartitions);
        }

    } while ((newValue.hashCode() % this.numPartitions) != newHashModValue);

    collector.emit(new Values(newValue));
}
 
開發者ID:uzh,項目名稱:storm-scheduler,代碼行數:26,代碼來源:IncreaseHashByOneFunction.java

示例3: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {

    String file = tuple.getString(0).replaceAll("\\s+","");
    String task = tuple.getString(1);
    String user = tuple.getString(2);
    String content = JSONObject.escape(tuple.getString(3));

    JSONObject json = new JSONObject();
    json.put("file",file);
    json.put("task",task);
    json.put("user",user);
    json.put("content",content);

    collector.emit(new Values(esIndex,task,file,json.toJSONString()));
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:17,代碼來源:PrepareDocForElasticSearch.java

示例4: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
    String url = tridentTuple.getString(0);

    Readability readability = null;
    Integer timeoutMillis = 5000;

    try {
        readability = new Readability(new URL(url), timeoutMillis);  // URL
        readability.init();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        return;
    }

    String webPageString = readability.content; //readability.outerHtml();
    String webPageTitle = readability.title;
    String hrefString = readability.hrefString.toString();

    //System.out.println("GetAdFreeWebPage: hrefString: \""+ hrefString+"\"");
    tridentCollector.emit(new Values(webPageString, webPageTitle, hrefString));
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:23,代碼來源:GetAdFreeWebPage.java

示例5: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
    public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
        String hrefList = tridentTuple.getString(0);
        Integer depth = Integer.parseInt(tridentTuple.getString(1));

        if(hrefList == null || hrefList.trim().length() == 0 || depth == 0)
            return;
        depth--;

//        System.out.println("PrepareHrefKafka: \""+hrefList+"\"");

        String[] hrefArray = hrefList.split(" ");
        for(String href : hrefArray) {
            tridentCollector.emit(new Values(href, depth.toString()));
        }
    }
 
開發者ID:skalmadka,項目名稱:web-crawler,代碼行數:17,代碼來源:PrepareHrefKafka.java

示例6: isKeep

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public boolean isKeep(TridentTuple tridentTuple) {

    String url = tridentTuple.getString(0);
    String task = tridentTuple.getString(1);

    //Remove contents after # in URL
    if (url.indexOf('#')!=-1)
        url = url.substring(0,url.indexOf('#'));


    if (bloomFilter.exists(task+"|"+url)) {
        System.out.println("----- BloomFilter reject (URL exists):" + url);
        return false;
    }
    bloomFilter.add(task+"|"+url);
    return true;
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:19,代碼來源:URLFilter.java

示例7: isKeep

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public boolean isKeep(TridentTuple tridentTuple) {
    String hrefList = tridentTuple.getString(0);
    Integer depth = Integer.parseInt(tridentTuple.getString(1));
    String task = tridentTuple.getString(2);
    String user = tridentTuple.getString(3);

    if(hrefList == null || hrefList.trim().length() == 0 || depth == 0)
        return true;//Always pass tuple downstream. However skip recursively adding this Href URL to kafka.
    depth--;

    String[] hrefArray = hrefList.split(" ");
    for(String href : hrefArray) {
        producer.send(new KeyedMessage<String, String>(kafkaTopic, href+" "+depth.toString()+" "+task+" "+user));
    }

    return true;
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:19,代碼來源:KafkaProducerFilter.java

示例8: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@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])));
}
 
開發者ID:amitchmca,項目名稱:hadooparchitecturebook,代碼行數:10,代碼來源:TickParser.java

示例9: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:zhangjunfang,項目名稱:jstorm-0.9.6.3-,代碼行數:9,代碼來源:ReturnResultsReducer.java

示例10: map

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public Document<String> map(TridentTuple tridentTuple) {
    String index = tridentTuple.getString(0);
    String type = tridentTuple.getString(1);
    String id = tridentTuple.getString(2);
    String source = tridentTuple.getString(3);
    System.out.println("ESTridentTupleMapper "+id);
    Document<String> esDocument = new Document<String>(index, type, source, id);
    return esDocument;
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:11,代碼來源:ESTridentTupleMapper.java

示例11: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
    String queryString = tridentTuple.getString(0);
    String taskName = tridentTuple.getString(1);

    String esQuery = QueryBuilders.matchQuery("content", queryString).buildAsBytes().toUtf8();
    tridentCollector.emit(new Values(esQuery,  Lists.newArrayList(esIndex), Lists.newArrayList(taskName)) );
}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:9,代碼來源:PrepareSearchQuery.java

示例12: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
public void execute(TridentTuple tuple, TridentCollector collector) {
    String str = tuple.getString(0);

    JSONParser parser=new JSONParser();
    try {
        Object obj = parser.parse(str);
        JSONObject jobj =  (JSONObject)(obj);
        collector.emit(new Values(jobj.get("filename"), jobj.get("task"), jobj.get("user"), jobj.get("content")));
    }
    catch (ParseException e) {
        e.printStackTrace();
        return;
    }

}
 
開發者ID:preems,項目名稱:realtime-event-processing,代碼行數:16,代碼來源:SplitDocStreamArgs.java

示例13: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
    String searchQuery = tridentTuple.getString(0);

    try {
        tridentCollector.emit(new Values(searchQuery));//Emit!!! Query itself
        if(suggestionsLimit >0)
            bingAutoSuggestEmitter(searchQuery, tridentCollector);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:skalmadka,項目名稱:web-crawler,代碼行數:13,代碼來源:BingAutoSuggest.java

示例14: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
    String args = tridentTuple.getString(0);
    String queryString = args;

    tridentCollector.emit(new Values(queryString));
}
 
開發者ID:skalmadka,項目名稱:web-crawler,代碼行數:8,代碼來源:SplitDRPCArgs.java

示例15: execute

import storm.trident.tuple.TridentTuple; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple input, TridentCollector collector) {
    String args = input.getString(0);
    List<List<Object>> tuples = (List) Utils.from_json(args);
    for(List<Object> tuple: tuples) {
        collector.emit(tuple);
    }
}
 
開發者ID:greeenSY,項目名稱:Tstream,代碼行數:9,代碼來源:TuplifyArgs.java


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