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


Java Tuple.getStringByField方法代碼示例

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


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

示例1: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
    final String word = tuple.getStringByField(Constraints.wordFileds);
    Integer count = tuple.getIntegerByField(Constraints.coinCountFileds);

    predictorHotKeyUtil.PredictorHotKey(word,count);

    if(predictorHotKeyUtil.isHotKey(word))
        collector.emit(new Values(word,1));

    predictorHotKeyUtil.SynopsisHashMapRandomDump(new DumpRemoveHandler() {
        @Override
        public void dumpRemove(String key) {
            collector.emit(new Values(word,1));
        }
    });

    collector.ack(tuple);
}
 
開發者ID:DStream-Storm,項目名稱:DStream,代碼行數:19,代碼來源:PredictorBolt.java

示例2: handle

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void handle(Tuple tuple) {
    EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
    List<PairWrapper<String, Object>> wrapperList = data.get(EmitData.MESSAGE);
    if (wrapperList != null && !wrapperList.isEmpty()) {
        for (PairWrapper<String, Object> wrapper : wrapperList) {
            HeartbeatPulse pulse = HeartbeatPulse.build(wrapper.pairs2map());
            if (logger.isDebugEnabled()) {
                Object offset = data.get(EmitData.OFFSET);
                HeartBeatPacket packet = HeartBeatPacket.parse(pulse.getPacket());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
                String groupId = tuple.getStringByField(Constants.EmitFields.GROUP_FIELD);
                logger.debug("[heartbeat] {} offset:{} ts:{}, time:{}", groupId, offset == null ? -1 : offset, packet.getTxtime(), format.format(new Date(packet.getTxtime())));
            }
            reporter.mark(pulse);
        }
    }

    handler.handle(tuple);
    this.listener.getOutputCollector().ack(tuple);
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:22,代碼來源:HeartbeatHandler.java

示例3: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
    if(tuple.getSourceComponent().equals(UPSTREAM_COMPONENT_ID)){
        String word = tuple.getStringByField(UPSTREAM_FIEDLS);
        if(word.length() <= 0) {
            collector.ack(tuple);
            return;
        }
        collector.emit(Constraints.coinFileds, new Values(word));
        Key ky = new Key(word.getBytes());
        if(bf.membershipTest(ky))
            collector.emit(Constraints.hotFileds, tuple, new Values(word));
        else
            collector.emit(Constraints.nohotFileds, tuple, new Values(word));

    }else {
        String key = tuple.getStringByField(Constraints.wordFileds);
        Integer type = tuple.getIntegerByField(Constraints.typeFileds);
        Key hk = new Key(key.getBytes());
        if(!bf.membershipTest(hk) && type.equals(1))
            bf.add(hk);
        if(bf.membershipTest(hk) && type.equals(0))
            bf.delete(hk);
    }
    collector.ack(tuple);
}
 
開發者ID:DStream-Storm,項目名稱:DStream,代碼行數:26,代碼來源:SplitterBolt.java

示例4: getResultofMax

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
/**
 * 聚合函數 max 計算結果
 *@param isJoin 是否含有join
 * @param tupleList 屬於某一個組的tuple list
 * @param parameter max(tab1.A) 參數值,目前僅支持一個參數
 * @return 該組tuple max 函數的執行結果
 */
private int getResultofMax(boolean isJoin, List<Tuple> tupleList, TCItem parameter) {
    int maxRes = Integer.MIN_VALUE;
    for (Tuple tuple : tupleList) {
        String tempKey = parameter.getTableName() + "." + parameter.getColName();
        if (!isJoin) {
            tempKey = parameter.getColName();
        }
        String tValStr = tuple.getStringByField(tempKey);
        if (!tValStr.isEmpty()) {
            int tVal = Integer.valueOf(tValStr);
            maxRes = Math.max(maxRes, tVal);
        }
    }
    return maxRes;
}
 
開發者ID:bigdataFlySQL,項目名稱:SQLonStorm,代碼行數:23,代碼來源:GroupByBolt.java

示例5: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void execute(Tuple tuple) {
    boltstatus++;

    String word = tuple.getStringByField(Constraints.wordFileds);
    if (!word.isEmpty()) {
        Long count = counts.get(word);
        if (count == null) {
            count = 0L;
        }
        count++;
        counts.put(word, count);
        outputCollector.emit(tuple,new Values(word,count));
    }
    outputCollector.ack(tuple);
}
 
開發者ID:DStream-Storm,項目名稱:DStream,代碼行數:17,代碼來源:WordCounterBolt.java

示例6: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
	String word = tuple.getStringByField("word");
	Long count = this.counts.get(word);
	if (count == null) {
		count = 0L;
	}
	count++;
	this.counts.put(word, count);
	this.collector.emit(new Values(word, count));
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:11,代碼來源:WordCountBolt.java

示例7: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
	String sentence = tuple.getStringByField("sentence");
	String[] words = sentence.split(" ");
	for (String word : words) {
		this.collector.emit(new Values(word));
	}
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:8,代碼來源:SplitSentenceBolt.java

示例8: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
   public void execute(Tuple tuple) {

       String url = tuple.getStringByField("url");
       Metadata metadata = (Metadata) tuple.getValueByField("metadata");

System.out.println("DummyIndexer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set to FETCHED url: " + url);

       _collector.emit(
               com.digitalpebble.stormcrawler.Constants.StatusStreamName,
               tuple, new Values(url, metadata, Status.FETCHED));
       _collector.ack(tuple);
   }
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:14,代碼來源:DummyIndexer.java

示例9: getTopic

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public String getTopic(Tuple tuple) {
    if (tuple.contains(fieldName)) {
        return tuple.getStringByField(fieldName);
    } else {
        LOG.warn("Field {} Not Found. Returning default topic {}", fieldName, defaultTopicName);
        return defaultTopicName;
    }
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:10,代碼來源:FieldNameTopicSelector.java

示例10: doSimulatorCommand

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void doSimulatorCommand(Tuple tuple) throws Exception {
    List<Values> values = new ArrayList<>();
    if (tuple.getFields().contains("command")) {
        String command = tuple.getStringByField("command");
        switch (command) {
            case SimulatorCommands.DO_ADD_SWITCH:
                //TODO: this is an ugly hack...
                if (tuple.getValueByField("data") instanceof AddSwitchCommand) {
                    values = addSwitch((AddSwitchCommand) tuple.getValueByField("data"));
                } else {
                    values = addSwitch((SwitchMessage) tuple.getValueByField("data"));
                }
                break;
            case SimulatorCommands.DO_ADD_LINK:
                values = addLink((AddLinkCommandMessage) tuple.getValueByField("data"));
                break;
            case SimulatorCommands.DO_PORT_MOD:
                values = modPort((PortModMessage) tuple.getValueByField("data"));
                break;
            default:
                logger.error(String.format("Uknown SimulatorCommand %s", command));
        }
    } else {
        SimulatorMessage message = (SimulatorMessage) tuple.getValueByField("data");
        if (message instanceof SwitchModMessage) {
            SwitchModMessage switchModMessage = (SwitchModMessage) message;
            ISwitchImpl sw = getSwitch(switchModMessage.getDpid());
            //            sw.mod(switchModMessage.getState());
        } else {
            logger.error("Unkown SimulatorMessage {}", message.getClass().getSimpleName());
        }
    }

    if (values.size() > 0) {
        for (Values value : values) {
            logger.debug("emitting: {}", value);
            collector.emit(SimulatorTopology.KAFKA_BOLT_STREAM, tuple, value);
        }
    }
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:41,代碼來源:SpeakerBolt.java

示例11: handle

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void handle(Tuple tuple) {
    EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
    String groupId = tuple.getStringByField(Constants.EmitFields.GROUP_FIELD);
    this.emitHeartbeat(listener.getOutputCollector(), tuple, groupId, data, Command.HEART_BEAT);
    if(logger.isDebugEnabled()) {
        Object offset = data.get(EmitData.OFFSET);
        logger.debug("[heartbeat] {} {} offset:{}", listener.getClass().getSimpleName(), groupId, offset == null ? -1 : offset);
    }
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:11,代碼來源:CommonHeartbeatHandler.java

示例12: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
    String sentence = input.getStringByField("value");
    for(int i=0;i<sentence.length();i++){
        char word = sentence.charAt(i);
        collector.emit(new Values(word+""));//分詞emit,隻有1個單詞的元組Tuple
    }
}
 
開發者ID:Paleozoic,項目名稱:storm_spring_boot_demo,代碼行數:9,代碼來源:SplitSentenceBolt.java

示例13: execute

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple tuple) {
	String word = tuple.getStringByField("word");
	Long count = tuple.getLongByField("count");
	this.counts.put(word, count);
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:6,代碼來源:DisplayBolt.java

示例14: afterBulk

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public void afterBulk(long executionId, BulkRequest request,
        BulkResponse response) {
    LOG.debug("afterBulk [{}] with {} responses", executionId,
            request.numberOfActions());
    long msec = response.getTookInMillis();
    eventCounter.scope("bulks_received").incrBy(1);
    eventCounter.scope("bulk_msec").incrBy(msec);
    Iterator<BulkItemResponse> bulkitemiterator = response.iterator();
    int itemcount = 0;
    int acked = 0;
    synchronized (waitAck) {
        while (bulkitemiterator.hasNext()) {
            BulkItemResponse bir = bulkitemiterator.next();
            itemcount++;
            String id = bir.getId();
            List<Tuple> xx = waitAck.getIfPresent(id);
            if (xx != null) {
                LOG.debug("Acked {} tuple(s) for ID {}", xx.size(), id);
                for (Tuple x : xx) {
                    acked++;
                    // ack and put in cache
                    super.ack(x, x.getStringByField("url"));
                }
                waitAck.invalidate(id);
            } else {
                LOG.warn("Could not find unacked tuple for {}", id);
            }
        }

        LOG.info("Bulk response [{}] : items {}, waitAck {}, acked {}",
                executionId, itemcount, waitAck.size(), acked);
        if (waitAck.size() > 0 && LOG.isDebugEnabled()) {
            for (String kinaw : waitAck.asMap().keySet()) {
                LOG.debug(
                        "Still in wait ack after bulk response [{}] => {}",
                        executionId, kinaw);
            }
        }
    }
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:42,代碼來源:StatusUpdaterBolt.java

示例15: create

import org.apache.storm.tuple.Tuple; //導入方法依賴的package包/類
/**
 * Create an item. Queue id will be created based on
 * <code>queueMode</code> argument, either as a protocol + hostname
 * pair, protocol + IP address pair or protocol+domain pair.
 */

public static FetchItem create(URL u, Tuple t, String queueMode) {

    String queueID;

    String url = u.toExternalForm();

    String key = null;
    // reuse any key that might have been given
    // be it the hostname, domain or IP
    if (t.contains("key")) {
        key = t.getStringByField("key");
    }
    if (StringUtils.isNotBlank(key)) {
        queueID = key.toLowerCase(Locale.ROOT);
        return new FetchItem(url, u, t, queueID);
    }

    if (FetchItemQueues.QUEUE_MODE_IP.equalsIgnoreCase(queueMode)) {
        try {
            final InetAddress addr = InetAddress.getByName(u.getHost());
            key = addr.getHostAddress();
        } catch (final UnknownHostException e) {
            LOG.warn(
                    "Unable to resolve IP for {}, using hostname as key.",
                    u.getHost());
            key = u.getHost();
        }
    } else if (FetchItemQueues.QUEUE_MODE_DOMAIN
            .equalsIgnoreCase(queueMode)) {
        key = PaidLevelDomain.getPLD(u.getHost());
        if (key == null) {
            LOG.warn(
                    "Unknown domain for url: {}, using hostname as key",
                    url);
            key = u.getHost();
        }
    } else {
        key = u.getHost();
    }

    if (key == null) {
        LOG.warn("Unknown host for url: {}, using URL string as key",
                url);
        key = u.toExternalForm();
    }

    queueID = key.toLowerCase(Locale.ROOT);
    return new FetchItem(url, u, t, queueID);
}
 
開發者ID:eorliac,項目名稱:patent-crawler,代碼行數:56,代碼來源:FetcherBolt.java


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