@Experimental(value=TRIGGER) public abstract class AfterDelayFromFirstElement extends Trigger.OnceTrigger
This class is for internal use only and may change at any time.
Trigger.MergingTriggerInfo, Trigger.OnceTrigger, Trigger.OnElementContext, Trigger.OnMergeContext, Trigger.TriggerContext, Trigger.TriggerInfo| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.beam.sdk.util.state.StateTag<Object,org.apache.beam.sdk.util.state.AccumulatorCombiningState<Instant,Combine.Holder<Instant>,Instant>> |
DELAYED_UNTIL_TAG |
protected static List<SerializableFunction<Instant,Instant>> |
IDENTITY |
protected List<SerializableFunction<Instant,Instant>> |
timestampMappers
A list of timestampMappers m1, m2, m3, ...
|
subTriggers| Constructor and Description |
|---|
AfterDelayFromFirstElement(org.apache.beam.sdk.util.TimeDomain timeDomain,
List<SerializableFunction<Instant,Instant>> timestampMappers) |
| Modifier and Type | Method and Description |
|---|---|
AfterDelayFromFirstElement |
alignedTo(Duration size)
Aligns the time to be the smallest multiple of
size greater than the timestamp
since the epoch. |
AfterDelayFromFirstElement |
alignedTo(Duration size,
Instant offset)
Aligns timestamps to the smallest multiple of
size since the offset greater
than the timestamp. |
void |
clear(Trigger.TriggerContext c)
Clear any state associated with this trigger in the given window.
|
protected Instant |
computeTargetTimestamp(Instant time) |
abstract Instant |
getCurrentTime(Trigger.TriggerContext context)
To complete an implementation, return the desired time from the TriggerContext.
|
Instant |
getWatermarkThatGuaranteesFiring(BoundedWindow window)
Returns a bound in watermark time by which this trigger would have fired at least once
for a given window had there been input data.
|
boolean |
isCompatible(Trigger other)
Returns whether this performs the same triggering as the given
Trigger. |
Trigger.OnceTrigger |
mappedTo(SerializableFunction<Instant,Instant> timestampMapper)
Deprecated.
This will be removed in the next major version. Please use only
plusDelayOf(org.joda.time.Duration) and alignedTo(org.joda.time.Duration, org.joda.time.Instant). |
protected abstract AfterDelayFromFirstElement |
newWith(List<SerializableFunction<Instant,Instant>> transform)
To complete an implementation, return a new instance like this one, but incorporating
the provided timestamp mapping functions.
|
void |
onElement(Trigger.OnElementContext c)
Called every time an element is incorporated into a window.
|
void |
onMerge(Trigger.OnMergeContext c)
Called immediately after windows have been merged.
|
protected void |
onOnlyFiring(Trigger.TriggerContext context)
Called exactly once by
Trigger.OnceTrigger.onFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) when the trigger is fired. |
AfterDelayFromFirstElement |
plusDelayOf(Duration delay)
Adds some delay to the original target time.
|
void |
prefetchOnElement(org.apache.beam.sdk.util.state.StateAccessor<?> state)
Called to allow the trigger to prefetch any state it will likely need to read from during
an
Trigger.onElement(org.apache.beam.sdk.transforms.windowing.Trigger.OnElementContext) call. |
void |
prefetchOnMerge(org.apache.beam.sdk.util.state.MergingStateAccessor<?,?> state)
Called to allow the trigger to prefetch any state it will likely need to read from during
an
Trigger.onMerge(org.apache.beam.sdk.transforms.windowing.Trigger.OnMergeContext) call. |
void |
prefetchShouldFire(org.apache.beam.sdk.util.state.StateAccessor<?> state)
Called to allow the trigger to prefetch any state it will likely need to read from during
an
Trigger.shouldFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) call. |
boolean |
shouldFire(Trigger.TriggerContext context)
Returns
true if the current state of the trigger indicates that its condition
is satisfied and it is ready to fire. |
getContinuationTrigger, onFireequals, getContinuationTrigger, hashCode, orFinally, prefetchOnFire, subTriggers, toStringprotected static final List<SerializableFunction<Instant,Instant>> IDENTITY
protected static final org.apache.beam.sdk.util.state.StateTag<Object,org.apache.beam.sdk.util.state.AccumulatorCombiningState<Instant,Combine.Holder<Instant>,Instant>> DELAYED_UNTIL_TAG
protected final List<SerializableFunction<Instant,Instant>> timestampMappers
public AfterDelayFromFirstElement(org.apache.beam.sdk.util.TimeDomain timeDomain,
List<SerializableFunction<Instant,Instant>> timestampMappers)
@Nullable public abstract Instant getCurrentTime(Trigger.TriggerContext context)
protected abstract AfterDelayFromFirstElement newWith(List<SerializableFunction<Instant,Instant>> transform)
public AfterDelayFromFirstElement alignedTo(Duration size, Instant offset)
size since the offset greater
than the timestamp.
TODO: Consider sharing this with FixedWindows, and bring over the equivalent of CalendarWindows.
public AfterDelayFromFirstElement alignedTo(Duration size)
size greater than the timestamp
since the epoch.public AfterDelayFromFirstElement plusDelayOf(Duration delay)
delay - the delay to add@Deprecated public Trigger.OnceTrigger mappedTo(SerializableFunction<Instant,Instant> timestampMapper)
plusDelayOf(org.joda.time.Duration) and alignedTo(org.joda.time.Duration, org.joda.time.Instant).public boolean isCompatible(Trigger other)
TriggerTrigger.isCompatible in class Triggerpublic void prefetchOnElement(org.apache.beam.sdk.util.state.StateAccessor<?> state)
TriggerTrigger.onElement(org.apache.beam.sdk.transforms.windowing.Trigger.OnElementContext) call.prefetchOnElement in class Triggerpublic void onElement(Trigger.OnElementContext c) throws Exception
Triggerpublic void prefetchOnMerge(org.apache.beam.sdk.util.state.MergingStateAccessor<?,?> state)
TriggerTrigger.onMerge(org.apache.beam.sdk.transforms.windowing.Trigger.OnMergeContext) call.prefetchOnMerge in class Triggerpublic void onMerge(Trigger.OnMergeContext c) throws Exception
TriggerLeaf triggers should update their state by inspecting their status and any state
in the merging windows. Composite triggers should update their state by calling
ExecutableTrigger.invokeOnMerge(org.apache.beam.sdk.transforms.windowing.Trigger.OnMergeContext) on their sub-triggers, and applying appropriate logic.
A trigger such as AfterWatermark.pastEndOfWindow() may no longer be finished;
it is the responsibility of the trigger itself to record this fact. It is forbidden for
a trigger to become finished due to Trigger.onMerge(org.apache.beam.sdk.transforms.windowing.Trigger.OnMergeContext), as it has not yet fired the pending
elements that led to it being ready to fire.
The implementation does not need to clear out any state associated with the old windows.
public void prefetchShouldFire(org.apache.beam.sdk.util.state.StateAccessor<?> state)
TriggerTrigger.shouldFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) call.prefetchShouldFire in class Triggerpublic void clear(Trigger.TriggerContext c) throws Exception
TriggerThis is called after a trigger has indicated it will never fire again. The trigger system keeps enough information to know that the trigger is finished, so this trigger should clear all of its state.
public Instant getWatermarkThatGuaranteesFiring(BoundedWindow window)
TriggerFor triggers that do not fire based on the watermark advancing, returns
BoundedWindow.TIMESTAMP_MAX_VALUE.
This estimate is used to determine that there are no elements in a side-input window, which causes the default value to be used instead.
getWatermarkThatGuaranteesFiring in class Triggerpublic boolean shouldFire(Trigger.TriggerContext context) throws Exception
Triggertrue if the current state of the trigger indicates that its condition
is satisfied and it is ready to fire.shouldFire in class TriggerExceptionprotected void onOnlyFiring(Trigger.TriggerContext context) throws Exception
Trigger.OnceTriggerTrigger.OnceTrigger.onFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) when the trigger is fired. By default,
invokes Trigger.OnceTrigger.onFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) on all subtriggers for which Trigger.shouldFire(org.apache.beam.sdk.transforms.windowing.Trigger.TriggerContext) is true.onOnlyFiring in class Trigger.OnceTriggerException