T
- The type of the elements produced by the source.@Public public static interface SourceFunction.SourceContext<T>
Modifier and Type | Method and Description |
---|---|
void |
close()
This method is called by the system to shut down the context.
|
void |
collect(T element)
Emits one element from the source, without attaching a timestamp.
|
void |
collectWithTimestamp(T element,
long timestamp)
Emits one element from the source, and attaches the given timestamp.
|
void |
emitWatermark(Watermark mark)
Emits the given
Watermark . |
Object |
getCheckpointLock()
Returns the checkpoint lock.
|
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 TimestampAssigner
on 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 emittimestamp
- The timestamp in milliseconds since the Epoch@PublicEvolving void emitWatermark(Watermark mark)
Watermark
. A Watermark of value t
declares that no
elements with a timestamp t' <= t
will occur any more. If further such
elements will be emitted, those elements are considered late.
This method is only relevant when running on TimeCharacteristic.EventTime
.
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 emitObject getCheckpointLock()
SourceFunction
for details about how to write a consistent checkpointed
source.void close()
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.