Flink 不理解AssignerWithPunctuatedWatermarks中checkAndGetNextWatermark方法的参数

ndasle7k  于 2023-03-06  发布在  Apache
关注(0)|答案(1)|浏览(122)

以下是AssignerWithPunctuatedWatermarks和checkAndGetNextWatermark的javadoc

*
 * <p>Timestamps and watermarks are defined as {@code longs} that represent the
 * milliseconds since the Epoch (midnight, January 1, 1970 UTC).
 * A watermark with a certain value {@code t} indicates that no elements with event
 * timestamps {@code x}, where {@code x} is lower or equal to {@code t}, will occur any more.
 *
 * @param <T> The type of the elements to which this assigner assigns timestamps.
 *
 * @see org.apache.flink.streaming.api.watermark.Watermark
 */
@Deprecated
public interface AssignerWithPunctuatedWatermarks<T> extends TimestampAssigner<T> {

    /**
     * Asks this implementation if it wants to emit a watermark. This method is called right after
     * the {@link #extractTimestamp(Object, long)} method.
     *
     * <p>The returned watermark will be emitted only if it is non-null and its timestamp
     * is larger than that of the previously emitted watermark (to preserve the contract of
     * ascending watermarks). If a null value is returned, or the timestamp of the returned
     * watermark is smaller than that of the last emitted one, then no new watermark will
     * be generated.
     *
     * <p>For an example how to use this method, see the documentation of
     * {@link AssignerWithPunctuatedWatermarks this class}.
     *
     * @return {@code Null}, if no watermark should be emitted, or the next watermark to emit.
     */
    @Nullable
    Watermark checkAndGetNextWatermark(T lastElement, long extractedTimestamp);
}

对于checkAndGetNextWatermark方法的参数,假设我有4条记录:A、B、C、D,按顺序排列(A第一,D最后),当我向watermak请求记录C时,下面两个语句是否正确?

  1. lastElement表示记录B
  2. extractedTimestamp表示记录C的时间戳
    另外,我想问为什么checkAndGetNextWatermark方法需要lastElement
    我看到我们团队的代码中有几处地方在实现checkAndGetNextWatermark方法时从lastElement中提取时间戳,如果上面两条语句是正确的,那么这是错误的。
lmyy7pcs

lmyy7pcs1#

lastElement表示记录C。这有点用词不当;它被称为 last 元素,因为水印处理是在记录被处理之后进行的。

相关问题