Java Code Examples for backtype.storm.tuple.Values

The following are top voted examples for showing how to use backtype.storm.tuple.Values. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: rb-bi   File: GetRadiusClient.java   View source code 6 votes vote down vote up
/**
 * <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));
}
 
Example 2
Project: rb-bi   File: MapperFunction.java   View source code 6 votes vote down vote up
/**
 * <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));
    }
}
 
Example 3
Project: rb-bi   File: SplitMSE10Data.java   View source code 6 votes vote down vote up
@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"));
        }
    }
}
 
Example 4
Project: rb-bi   File: MemcachedState.java   View source code 6 votes vote down vote up
@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));
}
 
Example 5
Project: rb-bi   File: MemcachedEventsLocationMseQuery.java   View source code 6 votes vote down vote up
@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));
    }
}
 
Example 6
Project: erad2016-streamprocessing   File: NegativeSentimentBolt.java   View source code 6 votes vote down vote up
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));
}
 
Example 7
Project: ignite-book-code-samples   File: WordCount.java   View source code 6 votes vote down vote up
@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);
}
 
Example 8
Project: rb-bi   File: GridGainEventsLocationMseQuery.java   View source code 6 votes vote down vote up
@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));
    }
}
 
Example 9
Project: Get-ENVS   File: SplitSentence.java   View source code 6 votes vote down vote up
@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));
    }
  }
}
 
Example 10
Project: RealEstate-Streaming   File: RouteBolt.java   View source code 6 votes vote down vote up
@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);
       
}
 
Example 11
Project: storm-hbase-1.0.x   File: HBaseState.java   View source code 6 votes vote down vote up
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;
}
 
Example 12
Project: storm-demos   File: KafkaDataSpout.java   View source code 6 votes vote down vote up
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);
		}
	}
}
 
Example 13
Project: RealEstate-Streaming   File: PhoenixJDBC.java   View source code 6 votes vote down vote up
@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);
       
}
 
Example 14
Project: splice-community-sample-code   File: MySqlSpout.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 15
Project: preliminary.demo   File: SpoutLocal.java   View source code 6 votes vote down vote up
@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;  
}
 
Example 16
Project: storm-kafka-examples   File: CheckOrderBolt.java   View source code 6 votes vote down vote up
@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));
				}
			}
		}
	}
}
 
Example 17
Project: miner   File: LoopSpout.java   View source code 6 votes vote down vote up
public void nextTuple(){
    try {
        Thread.sleep(20);
        Set<String> infoKeys = _redis.hkeys("message_loop");
        Iterator it = infoKeys.iterator();
        while (it.hasNext()){
            String tempKey = it.next().toString();
            if(!_redis.sismember("message_emit", tempKey)){
                String tempUrl = _redis.hget("message_loop", tempKey);
                String emitGlobalInfo = tempKey.split("-")[0]+"-"+tempKey.split("-")[1]+"-"+tempKey.split("-")[2];
                _collector.emit(new Values(emitGlobalInfo, tempUrl), tempKey);
                _redis.sadd("message_emit", tempKey);
                logger.info(tempKey+"--"+tempUrl + "  sending...");
                break;
            }
        }
    }catch (Exception e){
        logger.error("loopspout emit failed "+ e);
        e.printStackTrace();
    }
}
 
Example 18
Project: miner   File: GenerateUrlBolt.java   View source code 6 votes vote down vote up
public void execute(Tuple input, BasicOutputCollector collector) {


        try {
            String url = input.getString(0);
            if(url.length() > 10) {
                collector.emit(new Values(url));
                System.out.println(url);
            }else{
                System.err.println("======>loop back====>"+url);
            }
        }catch (Exception ex){
            logger.error("Generate Url error:"+ex);
            ex.printStackTrace();
        }
    }
 
Example 19
Project: erad2016-streamprocessing   File: PositiveSentimentBolt.java   View source code 6 votes vote down vote up
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));
}
 
Example 20
Project: erad2016-streamprocessing   File: TwitterFilterBolt.java   View source code 6 votes vote down vote up
public void execute(Tuple input, BasicOutputCollector collector) {
    LOGGER.debug("filttering incoming tweets");
    String json = input.getString(0);

    try {
        JsonNode root = mapper.readValue(json, JsonNode.class);

        long id;
        String text;

        if (root.get("lang") != null && "en".equals(root.get("lang").textValue())) {
            if (root.get("id") != null && root.get("text") != null) {
                id   = root.get("id").longValue();
                text = root.get("text").textValue();
                collector.emit(new Values(id, text));
            } else {
                LOGGER.debug("tweet id and/ or text was null");
            }
        } else {
            LOGGER.debug("Ignoring non-english tweet");
        }
    } catch (IOException ex) {
        LOGGER.error("IO error while filtering tweets", ex);
        LOGGER.trace(null, ex);
    }
}
 
Example 21
Project: Practical-Real-time-Processing-and-Analytics   File: FileSpout.java   View source code 5 votes vote down vote up
@Override
public void nextTuple() {
	try {
		String line = reader.readLine();
		if (line != null) {
			collector.emit(new Values(line));
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 22
Project: Practical-Real-time-Processing-and-Analytics   File: ParserBolt.java   View source code 5 votes vote down vote up
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
	String valueByField = input.getString(0);
	System.out.println("field value "+ valueByField);
	String[] split = valueByField.split(",");
	PacketDetailDTO tdrPacketDetailDTO = new PacketDetailDTO();
	tdrPacketDetailDTO.setPhoneNumber(Long.parseLong(split[0]));
	tdrPacketDetailDTO.setBin(Integer.parseInt(split[1]));
	tdrPacketDetailDTO.setBout(Integer.parseInt(split[2]));
	tdrPacketDetailDTO.setTimestamp(Long.parseLong(split[3]));

	collector.emit("tdrstream", new Values(tdrPacketDetailDTO));
}
 
Example 23
Project: Practical-Real-time-Processing-and-Analytics   File: FileSpout.java   View source code 5 votes vote down vote up
@Override
public void nextTuple() {
	try {
		String line = reader.readLine();
		if (line != null) {
			collector.emit(new Values(line));
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 24
Project: Practical-Real-time-Processing-and-Analytics   File: ParserBolt.java   View source code 5 votes vote down vote up
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
	String valueByField = input.getString(0);
	System.out.println("field value "+ valueByField);
	String[] split = valueByField.split(",");
	PacketDetailDTO tdrPacketDetailDTO = new PacketDetailDTO();
	tdrPacketDetailDTO.setPhoneNumber(Long.parseLong(split[0]));
	tdrPacketDetailDTO.setBin(Integer.parseInt(split[1]));
	tdrPacketDetailDTO.setBout(Integer.parseInt(split[2]));
	tdrPacketDetailDTO.setTimestamp(Long.parseLong(split[3]));

	collector.emit("tdrstream", new Values(tdrPacketDetailDTO));
}
 
Example 25
Project: Mastering-Apache-Storm   File: SampleSpout.java   View source code 5 votes vote down vote up
public void nextTuple() {
	// Storm cluster repeatedly call this method to emit the continuous //
	// stream of tuples.
	final Random rand = new Random();
	// generate the random number from 0 to 4.
	int randomNumber = rand.nextInt(5);
	spoutOutputCollector.emit (new Values(FIRSTNAMEMAP.get(randomNumber),LASTNAME.get(randomNumber),COMPANYNAME.get(randomNumber)));
}
 
Example 26
Project: rb-bi   File: StringKeyValueScheme.java   View source code 5 votes vote down vote up
@Override
public List<Object> deserializeKeyAndValue(byte[] key, byte[] value) {
    if ( key == null ) {
        return deserialize(value);
    }
    String keyString = StringScheme.deserializeString(key);
    String valueString = StringScheme.deserializeString(value);
    return new Values(ImmutableMap.of(keyString, valueString));
}
 
Example 27
Project: rb-bi   File: MapToJSONFunction.java   View source code 5 votes vote down vote up
/**
 * <p>This function converts a JAVA Map to JSON events.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    String eventJSON = "";
    try {
        eventJSON = _mapper.writeValueAsString((Map<String, Object>) tuple.getValue(0));
    } catch (IOException ex) {
        Logger.getLogger(MapToJSONFunction.class.getName()).log(Level.SEVERE, null, ex);
    }

    collector.emit(new Values(eventJSON));
}
 
Example 28
Project: rb-bi   File: PostgreSQLocation.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> flow = (Map<String, Object>) tuple.getValue(0);
    String wireless_station = (String) flow.get("wireless_station");

    if (wireless_station != null) {
         collector.emit(new Values(PostgresqlManager.get(wireless_station)));
    } else {
        collector.emit(new Values(new HashMap<String, Object>()));
    }
}
 
Example 29
Project: rb-bi   File: GetLocationClient.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, TridentCollector tridentCollector) {
    Map<String, Object> mseEvent = (Map<String, Object>) tuple.get(0);
    mseEventContent = (Map<String, Object>) mseEvent.get("StreamingNotification");
    location = (Map<String, Object>) mseEventContent.get("location");
    String macAddress = (String) location.get("macAddress");

    Map<String, Object> map = new HashMap<>();
    map.put("client_mac", macAddress);
    tridentCollector.emit(new Values(map));
}
 
Example 30
Project: rb-bi   File: GetNMSPInfoData.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> map = (Map<String, Object>) tuple.get(0);

    if (map != null) {
        Map<String, Object> data = new HashMap<>();
        data.putAll(map);
        data.remove("client_mac");

        Map<String, Object> druid = new HashMap<>();
        druid.put("bytes", 0);
        druid.put("pkts", 0);
        druid.put("timestamp", System.currentTimeMillis() / 1000);
        druid.putAll(map);
        druid.put("type", "nmsp-info");

        Object vlan = map.get("vlan_id");

        if (vlan != null) {
            druid.put("src_vlan", vlan);
            data.put("src_vlan", vlan);
            data.remove("vlan_id");
            druid.remove("vlan_id");
        }

        // logger.severe("Processed NMSP data info, emitting  [" + map.get("client_mac") + ", " + data.size() + ", " + druid.size() + "]");

        collector.emit(new Values(map.get("client_mac"), data, druid));
    }
}
 
Example 31
Project: rb-bi   File: CheckTimestampFunction.java   View source code 5 votes vote down vote up
/**
 * <p>This function check if the event contains the timestamp. If the event does not contain it creates it from the current time.</p>
 */
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> event = (Map<String, Object>) tuple.getValue(0);
    if(!event.containsKey("timestamp")){
        event.put("timestamp", System.currentTimeMillis()/1000);
        collector.emit(new Values(event));
    }else{
        collector.emit(new Values(event));
    }

}
 
Example 32
Project: rb-bi   File: MacVendorFunction.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
    Map<String, Object> event = (Map<String, Object>) tuple.getValue(0);
    Map<String, Object> vendorMap = new HashMap<>();
    String clientMac = (String) event.get("client_mac");

    if (clientMac != null) {
        String oui = buildOui(clientMac);
        if (_ouiMap.get(oui) != null)
            vendorMap.put("client_mac_vendor", _ouiMap.get(oui));
    }

    collector.emit(new Values(vendorMap));
}
 
Example 33
Project: rb-bi   File: MemcachedLocationV10Query.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        empty.put("dot11_status", "PROBING");
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
Example 34
Project: rb-bi   File: MemcachedTrapQuery.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        empty.put("client_rssi", "unknown");
        empty.put("client_rssi_num", 0);
        empty.put("client_snr", "unknown");
        empty.put("client_snr_num", 0);
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
Example 35
Project: rb-bi   File: MemcachedLocationQuery.java   View source code 5 votes vote down vote up
@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.put("dot11_status", "ASSOCIATED");
        collector.emit(new Values(result));
    }
}
 
Example 36
Project: rb-bi   File: MemcachedQuery.java   View source code 5 votes vote down vote up
@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 {
        collector.emit(new Values(result));
    }
}
 
Example 37
Project: rb-bi   File: RiakTrapQuery.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        empty.put("client_rssi", "unknown");
        empty.put("client_rssi_num", 0);
        empty.put("client_snr", "unknown");
        empty.put("client_snr_num", 0);
        //empty.put("quality", 0);
        collector.emit(new Values(empty));
    } else {
        collector.emit(new Values(result));
    }
}
 
Example 38
Project: erad2016-streamprocessing   File: StemmingBolt.java   View source code 5 votes vote down vote up
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));
}
 
Example 39
Project: rb-bi   File: RiakEventsLocationNmspQuery.java   View source code 5 votes vote down vote up
@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 {
        Map<String, Object> ap = new HashMap<>();
        ap.put("wireless_station", result.get("wireless_station"));
        collector.emit(new Values(ap));
    }
}
 
Example 40
Project: rb-bi   File: RiakLocationQuery.java   View source code 5 votes vote down vote up
@Override
public void execute(TridentTuple tuple, Map<String, Object> result, TridentCollector collector) {
    if (result == null) {
        Map<String, Object> empty = new HashMap<>();
        //empty.put("quality", 100);
        collector.emit(new Values(empty));
    } else {
        result.put("dot11_status", "ASSOCIATED");
        collector.emit(new Values(result));
    }
}