Package org.apache.beam.sdk.transforms
Class Watch.Growth<InputT,OutputT,KeyT>
java.lang.Object
org.apache.beam.sdk.transforms.PTransform<PCollection<InputT>,PCollection<KV<InputT,OutputT>>>
org.apache.beam.sdk.transforms.Watch.Growth<InputT,OutputT,KeyT>
- All Implemented Interfaces:
Serializable
,HasDisplayData
- Enclosing class:
Watch
public abstract static class Watch.Growth<InputT,OutputT,KeyT>
extends PTransform<PCollection<InputT>,PCollection<KV<InputT,OutputT>>>
Implementation of
Watch.growthOf(org.apache.beam.sdk.transforms.Watch.Growth.PollFn<InputT, OutputT>, org.apache.beam.sdk.transforms.Requirements)
.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A function that computes the current set of outputs for the given input, in the form of aWatch.Growth.PollResult
.static final class
The result of a single invocation of aWatch.Growth.PollFn
.static interface
A strategy for determining whether it is time to stop polling the current input regardless of whether its output is complete or not. -
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterIterations
<InputT> afterIterations
(int iterations) Returns aWatch.Growth.TerminationCondition
that holds after the given number of polling iterations have occurred per-input.static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTimeSinceNewOutput
<InputT> afterTimeSinceNewOutput
(SerializableFunction<InputT, ReadableDuration> timeSinceNewOutput) LikeafterTimeSinceNewOutput(ReadableDuration)
, but the duration is input-dependent.static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTimeSinceNewOutput
<InputT> afterTimeSinceNewOutput
(ReadableDuration timeSinceNewOutput) Returns aWatch.Growth.TerminationCondition
that holds after the given time has elapsed after the last time theWatch.Growth.PollResult
for the current input contained a previously unseen output.static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTotalOf
<InputT> afterTotalOf
(SerializableFunction<InputT, ReadableDuration> timeSinceInput) LikeafterTotalOf(ReadableDuration)
, but the duration is input-dependent.static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTotalOf
<InputT> afterTotalOf
(ReadableDuration timeSinceInput) Returns aWatch.Growth.TerminationCondition
that holds after the given time has elapsed after the current input was seen.static <InputT,
FirstStateT, SecondStateT>
org.apache.beam.sdk.transforms.Watch.Growth.BinaryCombined<InputT, FirstStateT, SecondStateT> allOf
(Watch.Growth.TerminationCondition<InputT, FirstStateT> first, Watch.Growth.TerminationCondition<InputT, SecondStateT> second) Returns aWatch.Growth.TerminationCondition
that holds when both of the given two conditions hold.static <InputT,
FirstStateT, SecondStateT>
org.apache.beam.sdk.transforms.Watch.Growth.BinaryCombined<InputT, FirstStateT, SecondStateT> eitherOf
(Watch.Growth.TerminationCondition<InputT, FirstStateT> first, Watch.Growth.TerminationCondition<InputT, SecondStateT> second) Returns aWatch.Growth.TerminationCondition
that holds when at least one of the given two conditions holds.expand
(PCollection<InputT> input) Override this method to specify how thisPTransform
should be expanded on the givenInputT
.static <InputT,
StateT>
Watch.Growth.TerminationCondition<InputT, StateT> ignoreInput
(Watch.Growth.TerminationCondition<?, StateT> condition) Wraps a given input-independentWatch.Growth.TerminationCondition
as an equivalent condition with a given input type, passingnull
to the original condition as input.static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.Never
<InputT> never()
Returns aWatch.Growth.TerminationCondition
that never holds (i.e., poll each input until its output is complete).withOutputCoder
(Coder<OutputT> outputCoder) Specifies aCoder
to use for the outputs.withOutputKeyCoder
(Coder<KeyT> outputKeyCoder) Specifies the coder for the output key.withPollInterval
(Duration pollInterval) Specifies how long to wait after a call toWatch.Growth.PollFn
before calling it again (if at all - according toWatch.Growth.PollResult
and theWatch.Growth.TerminationCondition
).withTerminationPerInput
(Watch.Growth.TerminationCondition<InputT, ?> terminationPerInput) Specifies aWatch.Growth.TerminationCondition
that will be independently used for every input.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
Constructor Details
-
Growth
public Growth()
-
-
Method Details
-
never
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.Never<InputT> never()Returns aWatch.Growth.TerminationCondition
that never holds (i.e., poll each input until its output is complete). -
ignoreInput
public static <InputT,StateT> Watch.Growth.TerminationCondition<InputT,StateT> ignoreInput(Watch.Growth.TerminationCondition<?, StateT> condition) Wraps a given input-independentWatch.Growth.TerminationCondition
as an equivalent condition with a given input type, passingnull
to the original condition as input. -
afterTotalOf
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTotalOf<InputT> afterTotalOf(ReadableDuration timeSinceInput) Returns aWatch.Growth.TerminationCondition
that holds after the given time has elapsed after the current input was seen. -
afterTotalOf
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTotalOf<InputT> afterTotalOf(SerializableFunction<InputT, ReadableDuration> timeSinceInput) LikeafterTotalOf(ReadableDuration)
, but the duration is input-dependent. -
afterTimeSinceNewOutput
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTimeSinceNewOutput<InputT> afterTimeSinceNewOutput(ReadableDuration timeSinceNewOutput) Returns aWatch.Growth.TerminationCondition
that holds after the given time has elapsed after the last time theWatch.Growth.PollResult
for the current input contained a previously unseen output. -
afterTimeSinceNewOutput
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterTimeSinceNewOutput<InputT> afterTimeSinceNewOutput(SerializableFunction<InputT, ReadableDuration> timeSinceNewOutput) LikeafterTimeSinceNewOutput(ReadableDuration)
, but the duration is input-dependent. -
afterIterations
public static <InputT> org.apache.beam.sdk.transforms.Watch.Growth.AfterIterations<InputT> afterIterations(int iterations) Returns aWatch.Growth.TerminationCondition
that holds after the given number of polling iterations have occurred per-input. Useful for deterministic testing of Watch users. -
eitherOf
public static <InputT,FirstStateT, org.apache.beam.sdk.transforms.Watch.Growth.BinaryCombined<InputT,SecondStateT> FirstStateT, eitherOfSecondStateT> (Watch.Growth.TerminationCondition<InputT, FirstStateT> first, Watch.Growth.TerminationCondition<InputT, SecondStateT> second) Returns aWatch.Growth.TerminationCondition
that holds when at least one of the given two conditions holds. -
allOf
public static <InputT,FirstStateT, org.apache.beam.sdk.transforms.Watch.Growth.BinaryCombined<InputT,SecondStateT> FirstStateT, allOfSecondStateT> (Watch.Growth.TerminationCondition<InputT, FirstStateT> first, Watch.Growth.TerminationCondition<InputT, SecondStateT> second) Returns aWatch.Growth.TerminationCondition
that holds when both of the given two conditions hold. -
withOutputKeyCoder
Specifies the coder for the output key. -
withTerminationPerInput
public Watch.Growth<InputT,OutputT, withTerminationPerInputKeyT> (Watch.Growth.TerminationCondition<InputT, ?> terminationPerInput) Specifies aWatch.Growth.TerminationCondition
that will be independently used for every input. -
withPollInterval
Specifies how long to wait after a call toWatch.Growth.PollFn
before calling it again (if at all - according toWatch.Growth.PollResult
and theWatch.Growth.TerminationCondition
). -
withOutputCoder
Specifies aCoder
to use for the outputs. If unspecified, it will be inferred from the output type ofWatch.Growth.PollFn
whenever possible.The coder must be deterministic, because the transform will compare encoded outputs for deduplication between polling rounds.
-
expand
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
method.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expand
in classPTransform<PCollection<InputT>,
PCollection<KV<InputT, OutputT>>>
-