T- The type of the elements produced by the source.
@Public public static interface SourceFunction.SourceContext<T>
|Modifier and Type||Method and Description|
This method is called by the system to shut down the context.
Emits one element from the source, without attaching a timestamp.
Emits one element from the source, and attaches the given timestamp.
Emits the given
Returns the checkpoint lock.
Marks the source to be temporarily idle.
void collect(T element)
The timestamp that the element will get assigned depends on the time characteristic of the streaming program:
TimeCharacteristic.ProcessingTime, the element has no timestamp.
TimeCharacteristic.IngestionTime, the element gets the system's current time as the timestamp.
TimeCharacteristic.EventTime, the element will have no timestamp initially. It needs to get a timestamp (via a
TimestampAssigner) before any time-dependent operation (like time windows).
element- The element to emit
@PublicEvolving void collectWithTimestamp(T element, long timestamp)
TimeCharacteristic.EventTime, where the sources assign timestamps themselves, rather than relying on a
TimestampAssigneron the stream.
On certain time characteristics, this timestamp may be ignored or overwritten. This allows programs to switch between the different time characteristics and behaviors without changing the code of the source functions.
TimeCharacteristic.ProcessingTime, the timestamp will be ignored, because processing time never works with element timestamps.
TimeCharacteristic.IngestionTime, the timestamp is overwritten with the system's current time, to realize proper ingestion time semantics.
TimeCharacteristic.EventTime, the timestamp will be used.
element- The element to emit
timestamp- The timestamp in milliseconds since the Epoch
@PublicEvolving void emitWatermark(Watermark mark)
Watermark. A Watermark of value
tdeclares that no elements with a timestamp
t' <= twill occur any more. If further such elements will be emitted, those elements are considered late.
This method is only relevant when running on
TimeCharacteristic.ProcessingTime,Watermarks will be ignored. On
TimeCharacteristic.IngestionTime, the Watermarks will be replaced by the
automatic ingestion time watermarks.
mark- The Watermark to emit
@PublicEvolving void markAsTemporarilyIdle()
TimeCharacteristic.EventTime, allowing downstream tasks to advance their watermarks without the need to wait for watermarks from this source while it is idle.
Source functions should make a best effort to call this method as soon as they
acknowledge themselves to be idle. The system will consider the source to resume activity
emitWatermark(Watermark) is called to emit elements or watermarks from the source.
SourceFunctionfor details about how to write a consistent checkpointed source.
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.