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


Java Values類代碼示例

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


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

示例1: nextTuple

import backtype.storm.tuple.Values; //導入依賴的package包/類
public void nextTuple() {
	Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
	topicCountMap.put(TopologyConfig.kafkaTopic, 1);//one excutor - one thread
	Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = conn.createMessageStreams(topicCountMap);
	List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(kafkaTopic);
	ConsumerIterator<byte[], byte[]> iter = streams.get(0).iterator();
	while(true){
		while(iter.hasNext()){
			
			String s = new String(iter.next().message());
			collector.emit(new Values(s));
			 
			UUID msgId = UUID.randomUUID();
			this.pending.put(msgId, new Values(s));
		}
		try {
			Thread.sleep(1000L);
		} catch (InterruptedException e) {
			logger.error("Spout : sleep wrong \n", e);
		}
	}
}
 
開發者ID:zhai3516,項目名稱:storm-demos,代碼行數:23,代碼來源:KafkaDataSpout.java

示例2: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
/**
 * <p>This function get the radius client from radius event.</p>
 * @author Andres Gomez
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> radiusData = (Map<String, Object>) tuple.getValue(0);

    String clientMac = radiusData.get("Calling-Station-Id").toString();
    clientMac = clientMac.replace("-", ":");
    
    Map<String, Object> radiusMap = new HashMap<>();
    
    radiusMap.put("client_mac", clientMac);
    
    if (_debug) {
        System.out.println(GetRadiusClient.class +" - Radius client to query: " + clientMac);
    }
    
    collector.emit(new Values(radiusMap));
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:22,代碼來源:GetRadiusClient.java

示例3: execute

import backtype.storm.tuple.Values; //導入依賴的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

示例4: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String , Object> mseData = (Map<String, Object>) tuple.get(0);
    List<Map<String, Object>> notifications = (List<Map<String, Object>>) mseData.get("notifications");

    for (Map<String, Object> notification : notifications){
        if(notification.get("notificationType").equals("association")){
            logger.fine("Mse10 event this event is a association, emitting: [" + notification.size() + ", " + "null]");
            collector.emit(new Values(notification, null));
        }else if(notification.get("notificationType").equals("locationupdate")){
            logger.fine("Mse10 event this event is a locationupdate, emitting: [null" + ", " + notification.size() + "]");
            collector.emit(new Values(null, notification));
        }else{
            Logger.getLogger(SplitMSE10Data.class.getName()).log(Level.WARNING, "MSE version 10 notificationType is unknown: " + notification.get("notificationType"));
        }
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:18,代碼來源:SplitMSE10Data.java

示例5: makeState

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public State makeState(Map conf, IMetricsContext context, int partitionIndex, int numPartitions) {
    MemcachedState s;
    try {
        s = new MemcachedState(makeMemcachedClient(_opts, _servers), _opts, _ser);
    } catch (UnknownHostException e) {
        throw new RuntimeException(e);
    }
    // s.registerMetrics(conf, context);
    CachedMap c = new CachedMap(s, _opts.localCacheSize);
    MapState ms;
    if(_type == StateType.NON_TRANSACTIONAL) {
        ms = NonTransactionalMap.build(c);
    } else if(_type==StateType.OPAQUE) {
        ms = OpaqueMap.build(c);
    } else if(_type==StateType.TRANSACTIONAL){
        ms = TransactionalMap.build(c);
    } else {
        throw new RuntimeException("Unknown state type: " + _type);
    }
    return new SnapshottableMap(ms, new Values(_opts.globalKey));
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:23,代碼來源:MemcachedState.java

示例6: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        collector.emit(new Values(empty));
    } else {
        result.remove("client_rssi");
        result.remove("client_rssi_num");
        result.remove("client_snr");
        result.remove("client_snr_num");
        result.remove("dot11_status");
        result.remove("wireless_id");

        collector.emit(new Values(result));
    }
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:17,代碼來源:MemcachedEventsLocationMseQuery.java

示例7: execute

import backtype.storm.tuple.Values; //導入依賴的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

示例8: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
    //Get the word contents from the tuple
    String word = tuple.getString(0);
    //Have we counted any already?
    Integer count = counts.get(word);
    if (count == null)
        count = 0;
    //Increment the count and store it
    count++;
    counts.put(word, count);
    //Emit the word and the current count
    //collector.emit(new Values(IGNITE_FIELD, count));
    TreeMap<String, Integer> words = new TreeMap<>();
    words.put(word,count);

    collector.emit(new Values(words));
    //Log information
    logger.info("Emitting a count of " + count + " for word " + word);
}
 
開發者ID:srecon,項目名稱:ignite-book-code-samples,代碼行數:21,代碼來源:WordCount.java

示例9: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
  //Get the sentence content from the tuple
  String sentence = tuple.getString(0);
  //An iterator to get each word
  BreakIterator boundary=BreakIterator.getWordInstance();
  //Give the iterator the sentence
  boundary.setText(sentence);
  //Find the beginning first word
  int start=boundary.first();
  //Iterate over each word and emit it to the output stream
  for (int end=boundary.next(); end != BreakIterator.DONE; start=end, end=boundary.next()) {
    //get the word
    String word=sentence.substring(start,end);
    //If a word is whitespace characters, replace it with empty
    word=word.replaceAll("\\s+","");
    //if it's an actual word, emit it
    if (!word.equals("")) {
      collector.emit(new Values(word));
    }
  }
}
 
開發者ID:mbad0la,項目名稱:Get-ENVS,代碼行數:23,代碼來源:SplitSentence.java

示例10: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(Tuple input) {
	LOG.info("About to process tuple[" + input + "]");
	
	List<Property> properties = new ArrayList<Property>();
	TruliaParser tp = new TruliaParser();
	
	// Process tuple by splitting into individual rows
	String rssfeed = input.getString(0);
	
	properties = tp.processRSS(rssfeed);
	
    for(Property prop : properties) {
    	outputCollector.emit(new Values(prop.getTitle(),
    			                        prop.getLink(),
    			                        prop.getDescription(),
    			                        prop.getPubDate(),
    			                        prop.getThumbnail()));
    }
	outputCollector.ack(input);
       
}
 
開發者ID:bucaojit,項目名稱:RealEstate-Streaming,代碼行數:23,代碼來源:RouteBolt.java

示例11: batchRetrieve

import backtype.storm.tuple.Values; //導入依賴的package包/類
public List<List<Values>> batchRetrieve(List<TridentTuple> tridentTuples) {
    List<List<Values>> batchRetrieveResult = Lists.newArrayList();
    List<Get> gets = Lists.newArrayList();
    for (TridentTuple tuple : tridentTuples) {
        byte[] rowKey = options.mapper.rowKey(tuple);
        gets.add(hBaseClient.constructGetRequests(rowKey, options.projectionCriteria));
    }

    try {
        Result[] results = hBaseClient.batchGet(gets);
        for(Result result : results) {
            List<Values> values = options.rowToStormValueMapper.toValues(result);
            batchRetrieveResult.add(values);
        }
    } catch (Exception e) {
        LOG.warn("Batch get operation failed. Triggering replay.", e);
        throw new FailedException(e);
    }
    return batchRetrieveResult;
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:21,代碼來源:HBaseState.java

示例12: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(Tuple input) {
	LOG.info("About to process tuple[" + input + "]");
	
      String sentence = input.getString(0);
      String[] words = sentence.split(" ");
      
      for(String word: words) {
         word = word.trim();
         
         if(!word.isEmpty()) {
            word = word.toLowerCase();
            outputCollector.emit(new Values(word));
         }
         
      }
      
      outputCollector.ack(input);
       
}
 
開發者ID:bucaojit,項目名稱:RealEstate-Streaming,代碼行數:21,代碼來源:PhoenixJDBC.java

示例13: nextTuple

import backtype.storm.tuple.Values; //導入依賴的package包/類
public void nextTuple() {
    if (bufferQueue.isEmpty()) {
        // pass in mysql server, db name, user, password
        seedBufferQueue("localhost", "test", "root", "");
        Utils.sleep(100);
    } else {
        // Replace name with the data being extracted.
        // This example expects only name to be returned in the sql/and thus is only item output by the spout.
        //  To add additional data add them to the values using new Values(value1, value2, etc) then emit the values
        String name = bufferQueue.poll();
        if (name != null) {
            Values values = new Values();
            values.add(name);
            _collector.emit(values);
        }
        Utils.sleep(50);
    }
}
 
開發者ID:splicemachine,項目名稱:splice-community-sample-code,代碼行數:19,代碼來源:MySqlSpout.java

示例14: consumeMessage

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
	for (MessageExt msg : msgs) {  
           byte[] body = msg.getBody();  
           if (body.length == 2 && body[0] == 0 && body[1] == 0) {  
                 
               LOG.error("Young:Got the end signal");  
               _collector.emit("stop",new Values("stop"));  
               continue;  
           }  
           if (msg.getTopic().equals(RaceConfig.MqPayTopic)) {  
               return doPayTopic(body);  
           }else if (msg.getTopic().equals(RaceConfig.MqTaobaoTradeTopic)) {  
               putTaobaoTradeToTair(body);  
               return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;  
           } else if (msg.getTopic().equals(RaceConfig.MqTmallTradeTopic)) {  
               putTmallTradeToTair(body);  
               return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;  
           }else {  
               return ConsumeConcurrentlyStatus.RECONSUME_LATER;  
           }  
       }  
       return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;  
}
 
開發者ID:yangliguang,項目名稱:preliminary.demo,代碼行數:25,代碼來源:SpoutLocal.java

示例15: execute

import backtype.storm.tuple.Values; //導入依賴的package包/類
@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//設置日期格式
	String nowData = df.format(new Date()); // new Date()為獲取當前係統時間,檢測是否為最新數據

	String data = tuple.getString(0);
	//訂單號		用戶id	     原金額	                      優惠價	          標示字段		下單時間
	//id		memberid  	totalprice					preprice		sendpay		createdate
	if(data!=null && data.length()>0) {
		String[] values = data.split("\t");
		if(values.length==6) {
			String id = values[0];
			String memberid = values[1];
			String totalprice = values[2];
			String preprice = values[3];
			String sendpay = values[4];
			String createdate = values[5];
			
			if(StringUtils.isNotEmpty(id)&&StringUtils.isNotEmpty(memberid)&&StringUtils.isNotEmpty(totalprice)) {
				if(DateUtils.isValidDate(createdate, nowData)) {
					collector.emit(new Values(id,memberid,totalprice,preprice,sendpay,createdate));
				}
			}
		}
	}
}
 
開發者ID:realxujiang,項目名稱:storm-kafka-examples,代碼行數:27,代碼來源:CheckOrderBolt.java


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