Package org.apache.beam.sdk.transforms
Annotation Interface DoFn.TruncateRestriction
Annotation for the method that truncates the restriction of a splittable
DoFn
into a bounded one.
This method is invoked when a pipeline is being drained.
This method is used to perform truncation of the restriction while it is not actively being processed.
Signature: @Nullable TruncateResult<RestrictionT> truncateRestriction(<arguments>);
This method must satisfy the following constraints:
- If one of its arguments is tagged with the
DoFn.Element
annotation, then it will be passed the current element being processed; the argument must be of typeInputT
. Note that automatic conversion ofRow
s andDoFn.FieldAccess
parameters are currently unsupported. - If one of its arguments is tagged with the
DoFn.Restriction
annotation, then it will be passed the current restriction being processed; the argument must be of typeRestrictionT
. - If one of its arguments is tagged with the
DoFn.Timestamp
annotation, then it will be passed the timestamp of the current element being processed; the argument must be of typeInstant
. - If one of its arguments is a
RestrictionTracker
, then it will be passed a tracker that is initialized for the currentDoFn.Restriction
. The argument must be of the exact typeRestrictionTracker<RestrictionT, PositionT>
. - If one of its arguments is a subtype of
BoundedWindow
, then it will be passed the window of the current element. When applied byParDo
the subtype ofBoundedWindow
must match the type of windows on the inputPCollection
. If the window is not accessed a runner may perform additional optimizations. - If one of its arguments is of type
PaneInfo
, then it will be passed information about the current triggering pane. - If one of the parameters is of type
PipelineOptions
, then it will be passed the options for the current pipeline.
Returns a truncated restriction representing a bounded amount of work that must be processed
before the pipeline can be drained or null
if no work is necessary.
The default behavior when a pipeline is being drained is that RestrictionTracker.IsBounded.BOUNDED
restrictions process entirely while RestrictionTracker.IsBounded.UNBOUNDED
restrictions process till a checkpoint is possible. Splittable DoFn
s should only
provide this method if they want to change this default behavior.