public abstract class DoFn.Context extends Object
DoFn.
Used primarily to output elements.| Constructor and Description |
|---|
Context() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract <AggInputT,AggOutputT> |
createAggregatorInternal(String name,
Combine.CombineFn<AggInputT,?,AggOutputT> combiner)
Creates an
Aggregator in the DoFn context with the
specified name and aggregation logic specified by Combine.CombineFn. |
abstract PipelineOptions |
getPipelineOptions()
|
abstract void |
output(OutputT output)
Adds the given element to the main output
PCollection. |
abstract void |
outputWithTimestamp(OutputT output,
Instant timestamp)
Adds the given element to the main output
PCollection,
with the given timestamp. |
protected void |
setupDelegateAggregators()
Sets up
Aggregators created by the DoFn so they are
usable within this context. |
abstract <T> void |
sideOutput(TupleTag<T> tag,
T output)
Adds the given element to the side output
PCollection with the
given tag. |
abstract <T> void |
sideOutputWithTimestamp(TupleTag<T> tag,
T output,
Instant timestamp)
Adds the given element to the specified side output
PCollection,
with the given timestamp. |
public abstract PipelineOptions getPipelineOptions()
PipelineOptions specified with the
PipelineRunner
invoking this DoFn. The PipelineOptions will
be the default running via DoFnTester.public abstract void output(OutputT output)
PCollection.
Once passed to output the element should be considered
immutable and not be modified in any way. It may be cached or retained
by the Dataflow runtime or later steps in the pipeline, or used in
other unspecified ways.
If invoked from processElement, the output
element will have the same timestamp and be in the same windows
as the input element passed to processElement.
If invoked from startBundle or finishBundle,
this will attempt to use the
WindowFn
of the input PCollection to determine what windows the element
should be in, throwing an exception if the WindowFn attempts
to access any information about the input element. The output element
will have a timestamp of negative infinity.
public abstract void outputWithTimestamp(OutputT output, Instant timestamp)
PCollection,
with the given timestamp.
Once passed to outputWithTimestamp the element should not be
modified in any way.
If invoked from processElement, the timestamp
must not be older than the input element's timestamp minus
getAllowedTimestampSkew. The output element will
be in the same windows as the input element.
If invoked from startBundle or finishBundle,
this will attempt to use the
WindowFn
of the input PCollection to determine what windows the element
should be in, throwing an exception if the WindowFn attempts
to access any information about the input element except for the
timestamp.
public abstract <T> void sideOutput(TupleTag<T> tag, T output)
PCollection with the
given tag.
Once passed to sideOutput the element should not be modified
in any way.
The caller of ParDo uses withOutputTags to
specify the tags of side outputs that it consumes. Non-consumed side
outputs, e.g., outputs for monitoring purposes only, don't necessarily
need to be specified.
The output element will have the same timestamp and be in the same
windows as the input element passed to processElement.
If invoked from startBundle or finishBundle,
this will attempt to use the
WindowFn
of the input PCollection to determine what windows the element
should be in, throwing an exception if the WindowFn attempts
to access any information about the input element. The output element
will have a timestamp of negative infinity.
public abstract <T> void sideOutputWithTimestamp(TupleTag<T> tag, T output, Instant timestamp)
PCollection,
with the given timestamp.
Once passed to sideOutputWithTimestamp the element should not be
modified in any way.
If invoked from processElement, the timestamp
must not be older than the input element's timestamp minus
getAllowedTimestampSkew. The output element will
be in the same windows as the input element.
If invoked from startBundle or finishBundle,
this will attempt to use the
WindowFn
of the input PCollection to determine what windows the element
should be in, throwing an exception if the WindowFn attempts
to access any information about the input element except for the
timestamp.
@Experimental(value=AGGREGATOR) protected abstract <AggInputT,AggOutputT> Aggregator<AggInputT,AggOutputT> createAggregatorInternal(String name, Combine.CombineFn<AggInputT,?,AggOutputT> combiner)
Aggregator in the DoFn context with the
specified name and aggregation logic specified by Combine.CombineFn.
For internal use only.
name - the name of the aggregatorcombiner - the Combine.CombineFn to use in the aggregatorCombine.CombineFn in this
context@Experimental(value=AGGREGATOR) protected final void setupDelegateAggregators()
Aggregators created by the DoFn so they are
usable within this context.
This method should be called by runners before DoFn.startBundle(org.apache.beam.sdk.transforms.DoFn<InputT, OutputT>.Context)
is executed.