Class DoFn.WindowedContext
- java.lang.Object
-
- org.apache.beam.sdk.transforms.DoFn.WindowedContext
-
- Direct Known Subclasses:
DoFn.OnTimerContext
,DoFn.OnWindowExpirationContext
,DoFn.ProcessContext
- Enclosing class:
- DoFn<InputT extends @Nullable java.lang.Object,OutputT extends @Nullable java.lang.Object>
public abstract class DoFn.WindowedContext extends java.lang.Object
Information accessible to all methods in thisDoFn
where the context is in some window.
-
-
Constructor Summary
Constructors Constructor Description WindowedContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract PipelineOptions
getPipelineOptions()
abstract <T> void
output(TupleTag<T> tag, T output)
Adds the given element to the outputPCollection
with the given tag.abstract void
output(OutputT output)
Adds the given element to the main outputPCollection
.abstract <T> void
outputWithTimestamp(TupleTag<T> tag, T output, org.joda.time.Instant timestamp)
Adds the given element to the specified outputPCollection
, with the given timestamp.abstract void
outputWithTimestamp(OutputT output, org.joda.time.Instant timestamp)
Adds the given element to the main outputPCollection
, with the given timestamp.
-
-
-
Method Detail
-
getPipelineOptions
@Pure public abstract PipelineOptions getPipelineOptions()
-
output
public abstract void output(OutputT output)
Adds the given element to the main outputPCollection
.Once passed to
output
the element should not be modified in any way.If invoked from
DoFn.ProcessElement
, the output element will have the same timestamp and be in the same windows as the input element passed to the method annotated with@ProcessElement
.If invoked from
DoFn.StartBundle
orDoFn.FinishBundle
, this will attempt to use theWindowFn
of the inputPCollection
to determine what windows the element should be in, throwing an exception if theWindowFn
attempts to access any information about the input element. The output element will have a timestamp of negative infinity.Note: A splittable
DoFn
is not allowed to output fromDoFn.StartBundle
orDoFn.FinishBundle
methods.
-
outputWithTimestamp
public abstract void outputWithTimestamp(OutputT output, org.joda.time.Instant timestamp)
Adds the given element to the main outputPCollection
, with the given timestamp.Once passed to
outputWithTimestamp
the element should not be modified in any way.If invoked from
DoFn.ProcessElement
), the timestamp must not be older than the input element's timestamp minusDoFn.getAllowedTimestampSkew()
. The output element will be in the same windows as the input element.If invoked from
DoFn.StartBundle
orDoFn.FinishBundle
, this will attempt to use theWindowFn
of the inputPCollection
to determine what windows the element should be in, throwing an exception if theWindowFn
attempts to access any information about the input element except for the timestamp.Note: A splittable
DoFn
is not allowed to output fromDoFn.StartBundle
orDoFn.FinishBundle
methods.
-
output
public abstract <T> void output(TupleTag<T> tag, T output)
Adds the given element to the outputPCollection
with the given tag.Once passed to
output
the element should not be modified in any way.The caller of
ParDo
usesParDo.SingleOutput.withOutputTags(org.apache.beam.sdk.values.TupleTag<OutputT>, org.apache.beam.sdk.values.TupleTagList)
to specify the tags of outputs that it consumes. Non-consumed 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
DoFn.ProcessElement
).If invoked from
DoFn.StartBundle
orDoFn.FinishBundle
, this will attempt to use theWindowFn
of the inputPCollection
to determine what windows the element should be in, throwing an exception if theWindowFn
attempts to access any information about the input element. The output element will have a timestamp of negative infinity.Note: A splittable
DoFn
is not allowed to output fromDoFn.StartBundle
orDoFn.FinishBundle
methods.
-
outputWithTimestamp
public abstract <T> void outputWithTimestamp(TupleTag<T> tag, T output, org.joda.time.Instant timestamp)
Adds the given element to the specified outputPCollection
, with the given timestamp.Once passed to
outputWithTimestamp
the element should not be modified in any way.If invoked from
DoFn.ProcessElement
), the timestamp must not be older than the input element's timestamp minusDoFn.getAllowedTimestampSkew()
. The output element will be in the same windows as the input element.If invoked from
DoFn.StartBundle
orDoFn.FinishBundle
, this will attempt to use theWindowFn
of the inputPCollection
to determine what windows the element should be in, throwing an exception if theWindowFn
attempts to access any information about the input element except for the timestamp.Note: A splittable
DoFn
is not allowed to output fromDoFn.StartBundle
orDoFn.FinishBundle
methods.
-
-