本文整理了Java中backtype.storm.tuple.Tuple.getValues()
方法的一些代码示例,展示了Tuple.getValues()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.getValues()
方法的具体详情如下:
包路径:backtype.storm.tuple.Tuple
类名称:Tuple
方法名:getValues
[英]Gets all the values in this tuple.
[中]
代码示例来源:origin: alibaba/jstorm
@Override
public void process(Object event) throws Exception {
Tuple tuple = (Tuple) event;
for (int boltTaskId : boltTasks) {
collector.emitDirectCtrl(boltTaskId, TopologyMaster.USER_DEFINED_STREAM, tuple.getValues());
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
collector.emit(input.getValues());
}
代码示例来源:origin: alibaba/jstorm
private long getRootId(Tuple input) {
int rootIdIndex = input.getValues().size() - 1;
return (long) input.getValue(rootIdIndex);
}
代码示例来源:origin: alibaba/jstorm
public void execute(Tuple input) {
String word = (String) input.getValues().get(0);
int count = (Integer) input.getValues().get(1);
_counts.put(word, count);
int globalCount = 0;
for (String w : _counts.keySet()) {
globalCount += _counts.get(w);
}
_collector.emit(tuple(globalCount));
_collector.ack(input);
}
代码示例来源:origin: alibaba/jstorm
public void execute(Tuple input, BasicOutputCollector collector) {
String word = (String) input.getValues().get(0);
int count = 0;
if (_counts.containsKey(word)) {
count = _counts.get(word);
}
count++;
_counts.put(word, count);
collector.emit(tuple(word, count));
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
long id = Utils.secureRandomLong();
List<Object> toEmit = new ArrayList<>();
toEmit.add(id);
toEmit.addAll(input.getValues());
collector.emit(toEmit);
}
代码示例来源:origin: alibaba/mdrill
@Override
public void execute(Tuple input, BasicOutputCollector collector) {
collector.emit(input.getValues());
}
代码示例来源:origin: alibaba/jstorm
/**
* Construct a new instance based on the provided {@link Tuple}.
* <p/>
* This method expects the object to be ranked in the first field (index 0)
* of the provided tuple, and the number of occurrences of the object (its
* count) in the second field (index 1). Any further fields in the tuple
* will be extracted and tracked, too. These fields can be accessed via
* {@link RankableObjectWithFields#getFields()}.
*
* @param tuple
*
* @return new instance based on the provided tuple
*/
public static RankableObjectWithFields from(Tuple tuple) {
List<Object> otherFields = Lists.newArrayList(tuple.getValues());
Object obj = otherFields.remove(0);
Long count = (Long) otherFields.remove(0);
return new RankableObjectWithFields(obj, count, otherFields.toArray());
}
代码示例来源:origin: alibaba/jstorm
@Override
public void execute(Tuple tuple, Object state, TimeWindow window) {
LOG.info("executing on window:{}", window);
Map<String, Integer> counts = (Map<String, Integer>) state;
List<Object> partialWordCounts = tuple.getValues();
for (Object partialWordCount : partialWordCounts) {
Pair<String, Integer> pair = (Pair<String, Integer>) partialWordCount;
counts.put(pair.getFirst(), pair.getSecond());
}
}
代码示例来源:origin: alibaba/mdrill
public void execute(Tuple input) {
String word = (String) input.getValues().get(0);
int count = (Integer) input.getValues().get(1);
_counts.put(word, count);
int globalCount = 0;
for(String w: _counts.keySet()) {
globalCount+=_counts.get(w);
}
_collector.emit(tuple(globalCount));
_collector.ack(input);
}
代码示例来源:origin: alibaba/mdrill
public void execute(Tuple input, BasicOutputCollector collector) {
String word = (String) input.getValues().get(0);
int count = 0;
if(_counts.containsKey(word)) {
count = _counts.get(word);
}
count++;
_counts.put(word, count);
collector.emit(tuple(word, count));
}
代码示例来源:origin: alibaba/jstorm
public void execute(Tuple input) {
String component = input.getSourceComponent();
Map<String, List<FixedTuple>> captured = emitted_tuples.get(_name);
if (!captured.containsKey(component)) {
captured.put(component, new ArrayList<FixedTuple>());
}
captured.get(component).add(new FixedTuple(input.getSourceStreamId(), input.getValues()));
_collector.ack(input);
}
代码示例来源:origin: alibaba/jstorm
public void execute(Tuple tuple) {
if (tuple.getValues().size() == 0) {
_expectExcevieNum--;
} else {
JStormUtils.sleepMs(1);
_collector.emit(tuple, new Values(tuple.getValues()));
_collector.ack(tuple);
}
}
代码示例来源:origin: alibaba/mdrill
public void execute(Tuple input) {
String component = input.getSourceComponent();
Map<String, List<FixedTuple>> captured = emitted_tuples.get(_name);
if(!captured.containsKey(component)) {
captured.put(component, new ArrayList<FixedTuple>());
}
captured.get(component).add(new FixedTuple(input.getSourceStreamId(), input.getValues()));
_collector.ack(input);
}
代码示例来源:origin: alibaba/jstorm
public TridentTuple create(Tuple parent) {
return new TridentTupleView(PersistentVector.EMPTY.cons(parent.getValues()), index, fieldIndex);
}
代码示例来源:origin: alibaba/mdrill
public long crc32(Tuple tuple) {
try {
CRC32OutputStream hasher = new CRC32OutputStream();
_kryo.serializeInto(tuple.getValues(), hasher);
return hasher.getValue();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: alibaba/jstorm
private void processTupleBatchEvent(Tuple tuple) {
try {
if ((!isSystemBolt && tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID)) ||
tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_REGISTER_METRICS_RESP_STREAM_ID)) {
if (tuple.getValues().get(0) instanceof Pair) {
for (Object value : tuple.getValues()) {
Pair<MessageId, List<Object>> val = (Pair<MessageId, List<Object>>) value;
TupleImplExt t = new TupleImplExt(
sysTopologyCtx, val.getSecond(), val.getFirst(), ((TupleImplExt) tuple));
processTupleEvent(t);
}
}
} else {
bolt.execute(tuple);
}
} catch (Throwable e) {
error = e;
LOG.error("bolt execute error ", e);
reportError.report(e);
}
}
代码示例来源:origin: alibaba/jstorm
@Override
public void process(Object event) throws Exception {
if (event instanceof UpdateConfigEvent) {
update(((UpdateConfigEvent) event).getConf());
return;
}
Tuple input = (Tuple) event;
TopoMasterCtrlEvent ctlEvent = (TopoMasterCtrlEvent) input.getValues().get(0);
if (ctlEvent != null) {
if (ctlEvent.isTransactionEvent()) {
snapshotStateMaster.process(input);
} else {
String errorInfo = "Received unexpected control event, {}" + event.toString();
LOG.warn(errorInfo);
zkCluster.report_task_error(context.getTopologyId(), context.getThisTaskId(),
errorInfo, ErrorConstants.WARN, ErrorConstants.CODE_USER);
}
}
}
代码示例来源:origin: alibaba/mdrill
public byte[] serialize(Tuple tuple) {
try {
_outputter.reset();
WritableUtils.writeVInt(_dataOutputter, tuple.getSourceTask());
WritableUtils.writeVInt(_dataOutputter, _ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId()));
tuple.getMessageId().serialize(_dataOutputter);
_kryo.serializeInto(tuple.getValues(), _outputter);
return _outputter.toByteArray();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: alibaba/jstorm
private BoltMsg createBoltMessage(Tuple input, String genId) {
BoltMsg boltMsg = new BoltMsg();
boltMsg.setId(genId);
boltMsg.setComp(input.getSourceComponent());
boltMsg.setStream(input.getSourceStreamId());
boltMsg.setTask(input.getSourceTask());
boltMsg.setTuple(input.getValues());
return boltMsg;
}
内容来源于网络,如有侵权,请联系作者删除!