本文整理匯總了Java中backtype.storm.tuple.Tuple.getValueByField方法的典型用法代碼示例。如果您正苦於以下問題:Java Tuple.getValueByField方法的具體用法?Java Tuple.getValueByField怎麽用?Java Tuple.getValueByField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類backtype.storm.tuple.Tuple
的用法示例。
在下文中一共展示了Tuple.getValueByField方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public void execute(Tuple input, BasicOutputCollector arg1) {
PacketDetailDTO packetDetailDTO = (PacketDetailDTO) input.getValueByField("tdrstream");
System.out.println("field value "+ packetDetailDTO);
session.execute("INSERT INTO packet_tdr (phone_number, bin, bout, timestamp) VALUES ("
+ packetDetailDTO.getPhoneNumber()
+ ", "
+ packetDetailDTO.getBin()
+ ","
+ packetDetailDTO.getBout()
+ "," + packetDetailDTO.getTimestamp() + ")");
}
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:13,代碼來源:TDRCassandraBolt.java
示例2: getKeyFromTuple
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public K getKeyFromTuple(Tuple tuple) {
//for backward compatibility, we return null when key is not present.
return tuple.contains(boltKeyField) ? (K) tuple.getValueByField(boltKeyField) : null;
}
示例3: getMessageFromTuple
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public V getMessageFromTuple(Tuple tuple) {
return (V) tuple.getValueByField(boltMessageField);
}
示例4: rowKey
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
public byte[] rowKey(Tuple tuple) {
Object objVal = tuple.getValueByField(this.rowKeyField);
return toBytes(objVal);
}
示例5: map
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
@Override
public byte[] map(Tuple tuple) {
String inputValue = (String) tuple.getValueByField(inputFieldName);
return inputValue.getBytes();
}
示例6: execute
import backtype.storm.tuple.Tuple; //導入方法依賴的package包/類
/**
* Process a single tuple of input. The Tuple object contains metadata on it
* about which component/stream/task it came from. The values of the Tuple can
* be accessed using Tuple#getValue. The IBolt does not have to process the Tuple
* immediately. It is perfectly fine to hang onto a tuple and process it later
* (for instance, to do an aggregation or join).
* <p/>
* <p>Tuples should be emitted using the OutputCollector provided through the prepare method.
* It is required that all input tuples are acked or failed at some point using the OutputCollector.
* Otherwise, Storm will be unable to determine when tuples coming off the spouts
* have been completed.</p>
* <p/>
* <p>For the common case of acking an input tuple at the end of the execute method,
* see IBasicBolt which automates this.</p>
*
* @param input The input tuple to be processed.
*/
@Override
public void execute(Tuple input) {
DataPoint dp = (DataPoint)input.getValueByField(Constants.DATA_POINT);
String measureId = getMeasureId(topic, dp.getSource());
dp.setSource(measureId);
//this guy gets persisted to TSDB
tsdbHandler.persist(dp.getSource()
, dp
, TimeseriesDatabaseHandlers.getTags(dp
, TimeseriesDatabaseHandlers.RAW_TYPE
, persistenceConfig.getTags()
)
, TimeseriesDatabaseHandlers.EMPTY_CALLBACK
);
//now let's look for outliers
Outlier outlier = sketchyOutlierAlgorithm.analyze(dp);
if(outlier.getSeverity() == Severity.SEVERE_OUTLIER) {
outlier = batchOutlierAlgorithm.analyze(outlier, outlier.getSample(), dp);
if(outlier.getSeverity() == Severity.SEVERE_OUTLIER) {
tsdbHandler.persist(dp.getSource()
, dp
, TimeseriesDatabaseHandlers.getTags(dp
, TimeseriesDatabaseHandlers.OUTLIER_TYPE
, persistenceConfig.getTags()
)
, TimeseriesDatabaseHandlers.EMPTY_CALLBACK
);
try {
Map<String, Object> json = OutlierHelper.INSTANCE.toJson(dp);
//LOG.info(json);
_collector.emit(STREAM_ID, ImmutableList.<Object>of(json));
} catch (RuntimeException e) {
LOG.error(e.getMessage(), e);
}
}
}
_collector.ack(input);
}