org.apache.storm.tuple.Tuple.getIntegerByField()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.apache.storm.tuple.Tuple.getIntegerByField()方法的一些代码示例,展示了Tuple.getIntegerByField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.getIntegerByField()方法的具体详情如下:
包路径:org.apache.storm.tuple.Tuple
类名称:Tuple
方法名:getIntegerByField

Tuple.getIntegerByField介绍

[英]Gets the Integer field with a specific name.
[中]获取具有特定名称的整数字段。

代码示例

代码示例来源:origin: apache/storm

public static TimeData fromTuple(Tuple tuple) {
  return new TimeData(tuple.getIntegerByField(NUMBER_FIELD_NAME), new Date(tuple.getLongByField(TIMESTAMP_FIELD_NAME)));
}

代码示例来源:origin: apache/storm

@Override
public void execute(TupleWindow inputWindow) {
  for (Tuple tuple : inputWindow.get()) {
    sum += tuple.getIntegerByField("value");
  }
  state.put("sum", sum);
  collector.emit(new Values(sum));
}

代码示例来源:origin: apache/metron

/**
 * This bolt consumes telemetry messages and determines if the message is needed
 * by any of the profiles.  The message is then routed to one or more downstream
 * bolts that are responsible for building each profile
 *
 * <p>The outgoing tuples are timestamped so that Storm's window and event-time
 * processing functionality can recognize the time of each message.
 *
 * <p>The timestamp that is attached to each outgoing tuple is what decides if
 * the Profiler is operating on processing time or event time.
 *
 * @param input The tuple.
 */
@Override
public void execute(Tuple input) {
 try {
  LOG.debug("Received message; topic={}, partition={}, offset={}, kafkaTimestamp={}",
      input.contains(TOPIC.getFieldName())      ? input.getStringByField(TOPIC.getFieldName()):       "unknown",
      input.contains(PARTITION.getFieldName())  ? input.getIntegerByField(PARTITION.getFieldName()):  "unknown",
      input.contains(OFFSET.getFieldName())     ? input.getLongByField(OFFSET.getFieldName()):        "unknown",
      input.contains(TIMESTAMP.getFieldName())  ? input.getLongByField(TIMESTAMP.getFieldName()):     "unknown");
  doExecute(input);
 } catch (Throwable t) {
  LOG.error("Unexpected error", t);
  collector.reportError(t);
 } finally {
  collector.ack(input);
 }
}

相关文章