当前位置: 首页>>代码示例>>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;未经允许,请勿转载。