public static class StreamSource.NonTimestampContext<T> extends Object implements SourceFunction.SourceContext<T>
-1
as a timestamp to all records, and that
does not forward watermarks.Constructor and Description |
---|
NonTimestampContext(StreamSource<?,?> owner,
Object lockingObject,
Output<StreamRecord<T>> output) |
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.
|
public NonTimestampContext(StreamSource<?,?> owner, Object lockingObject, Output<StreamRecord<T>> output)
public void collect(T element)
SourceFunction.SourceContext
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).collect
in interface SourceFunction.SourceContext<T>
element
- The element to emitpublic void collectWithTimestamp(T element, long timestamp)
SourceFunction.SourceContext
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.collectWithTimestamp
in interface SourceFunction.SourceContext<T>
element
- The element to emittimestamp
- The timestamp in milliseconds since the Epochpublic void emitWatermark(Watermark mark)
SourceFunction.SourceContext
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.
emitWatermark
in interface SourceFunction.SourceContext<T>
mark
- The Watermark to emitpublic Object getCheckpointLock()
SourceFunction.SourceContext
SourceFunction
for details about how to write a consistent checkpointed
source.getCheckpointLock
in interface SourceFunction.SourceContext<T>
public void close()
SourceFunction.SourceContext
close
in interface SourceFunction.SourceContext<T>
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.