org.apache.flink.streaming.api.operators.Output类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(112)

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

Output介绍

[英]A org.apache.flink.streaming.api.operators.StreamOperator is supplied with an object of this interface that can be used to emit elements and other messages, such as barriers and watermarks, from an operator.
[中]一个组织。阿帕奇。弗林克。流动。应用程序编程接口。接线员。StreamOperator提供了此接口的一个对象,可用于从操作员发出元素和其他消息,如屏障和水印。

代码示例

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

/**
 * Write skipped late arriving element to SideOutput.
 *
 * @param element skipped late arriving element to side output
 */
protected void sideOutput(StreamRecord<IN> element){
  output.collect(lateDataOutputTag, element);
}

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

@Override
protected void processAndCollect(T element) {
  lastRecordTime = this.timeService.getCurrentProcessingTime();
  output.collect(reuse.replace(element, lastRecordTime));
  // this is to avoid lock contention in the lockingObject by
  // sending the watermark before the firing of the watermark
  // emission task.
  if (lastRecordTime > nextWatermarkTime) {
    // in case we jumped some watermarks, recompute the next watermark time
    final long watermarkTime = lastRecordTime - (lastRecordTime % watermarkInterval);
    nextWatermarkTime = watermarkTime + watermarkInterval;
    output.emitWatermark(new Watermark(watermarkTime));
    // we do not need to register another timer here
    // because the emitting task will do so.
  }
}

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

@Override
  public void close() {
    for (Output<StreamRecord<T>> output : outputs) {
      output.close();
    }
  }
}

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

@Override
public void emitWatermark(Watermark mark) {
  output.emitWatermark(mark);
}

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

@Override
public void emitLatencyMarker(LatencyMarker latencyMarker) {
  output.emitLatencyMarker(latencyMarker);
}

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

@Override
protected void processAndEmitWatermark(Watermark mark) {
  output.emitWatermark(mark);
}

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

@Override
public void emitLatencyMarker(LatencyMarker latencyMarker) {
  if (outputs.length <= 0) {
    // ignore
  } else if (outputs.length == 1) {
    outputs[0].emitLatencyMarker(latencyMarker);
  } else {
    // randomly select an output
    outputs[random.nextInt(outputs.length)].emitLatencyMarker(latencyMarker);
  }
}

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

@Override
public void collect(StreamRecord<T> record) {
  for (Output<StreamRecord<T>> output : outputs) {
    output.collect(record);
  }
}

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

@Override
public void processElement(StreamRecord<T> element) throws Exception {
  long newTimestamp = userFunction.extractTimestamp(element.getValue(), element.getTimestamp());
  output.collect(element.replace(element.getValue(), newTimestamp));
  long watermark = userFunction.extractWatermark(element.getValue(), newTimestamp);
  if (watermark > currentWatermark) {
    currentWatermark = watermark;
    output.emitWatermark(new Watermark(currentWatermark));
  }
}

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

/** This will only be called if allowWatermark returned {@code true}. */
@Override
protected void processAndEmitWatermark(Watermark mark) {
  nextWatermarkTime = Long.MAX_VALUE;
  output.emitWatermark(mark);
  // we can shutdown the watermark timer now, no watermarks will be needed any more.
  // Note that this procedure actually doesn't need to be synchronized with the lock,
  // but since it's only a one-time thing, doesn't hurt either
  final ScheduledFuture<?> nextWatermarkTimer = this.nextWatermarkTimer;
  if (nextWatermarkTimer != null) {
    nextWatermarkTimer.cancel(true);
  }
}

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

@Override
public void close() {
  for (Output<StreamRecord<OUT>> out : allOutputs) {
    out.close();
  }
}

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

@Override
public void emitLatencyMarker(LatencyMarker latencyMarker) {
  // randomly select an output
  allOutputs[random.nextInt(allOutputs.length)].emitLatencyMarker(latencyMarker);
}

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

@Override
public <X> void collect(OutputTag<X> outputTag, StreamRecord<X> record) {
  for (Output<StreamRecord<T>> output : outputs) {
    output.collect(outputTag, record);
  }
}

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

@Override
public void processElement(StreamRecord<T> element) throws Exception {
  final T value = element.getValue();
  final long newTimestamp = userFunction.extractTimestamp(value,
      element.hasTimestamp() ? element.getTimestamp() : Long.MIN_VALUE);
  output.collect(element.replace(element.getValue(), newTimestamp));
  final Watermark nextWatermark = userFunction.checkAndGetNextWatermark(value, newTimestamp);
  if (nextWatermark != null && nextWatermark.getTimestamp() > currentWatermark) {
    currentWatermark = nextWatermark.getTimestamp();
    output.emitWatermark(nextWatermark);
  }
}

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

public void processWatermark(Watermark mark) throws Exception {
  if (timeServiceManager != null) {
    timeServiceManager.advanceWatermark(mark);
  }
  output.emitWatermark(mark);
}

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

@Override
  public void close() {
    output.close();
  }
}

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

protected void reportOrForwardLatencyMarker(LatencyMarker marker) {
  // all operators are tracking latencies
  this.latencyStats.reportLatency(marker);
  // everything except sinks forwards latency markers
  this.output.emitLatencyMarker(marker);
}

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

@Override
public void processElement(StreamRecord<IN> record) throws Exception {
  output.collect(record);
}

代码示例来源:origin: org.apache.flink/flink-streaming-java

@Override
public void processElement(StreamRecord<T> element) throws Exception {
  long newTimestamp = userFunction.extractTimestamp(element.getValue(), element.getTimestamp());
  output.collect(element.replace(element.getValue(), newTimestamp));
  long watermark = userFunction.extractWatermark(element.getValue(), newTimestamp);
  if (watermark > currentWatermark) {
    currentWatermark = watermark;
    output.emitWatermark(new Watermark(currentWatermark));
  }
}

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

@Override
  public void processWatermark(Watermark mark) throws Exception {
    output.emitWatermark(mark);
  }
}

相关文章