本文整理汇总了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));
}
}
示例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));
}
示例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()));
}
示例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));
}
示例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()));
}
}
示例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;
}
示例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;
}
示例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])));
}
示例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);
}
}
示例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;
}
示例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)) );
}
示例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;
}
}
示例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();
}
}
示例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));
}
示例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);
}
}