I - the type of the (main) input elementsO - the type of the (main) output elementspublic static class RateLimiting.RateLimitingTransform<I,O> extends PTransform<PCollection<? extends I>,PCollection<O>>
PTransform which applies rate limiting to a DoFn.name| Constructor and Description |
|---|
RateLimiting.RateLimitingTransform(DoFn<I,O> doFn) |
| Modifier and Type | Method and Description |
|---|---|
PCollection<O> |
apply(PCollection<? extends I> input)
Applies this
PTransform on the given Input, and returns its
Output. |
RateLimiting.RateLimitingTransform<I,O> |
withMaxParallelism(int max)
Modifies this
RateLimitingTransform, specifying a maximum
per-worker parallelism. |
RateLimiting.RateLimitingTransform<I,O> |
withRateLimit(double maxElementsPerSecond)
Modifies this
RateLimitingTransform, specifying a maximum
per-worker element processing rate. |
finishSpecifying, getCoderRegistry, getDefaultName, getDefaultOutputCoder, getDefaultOutputCoder, getInput, getKindString, getName, getOutput, getPipeline, setName, setPipeline, toString, withNamepublic RateLimiting.RateLimitingTransform<I,O> withRateLimit(double maxElementsPerSecond)
RateLimitingTransform, specifying a maximum
per-worker element processing rate.
A rate of N corresponds to N elements per second.
This rate is on a per-worker basis, so the overall rate of the job
depends upon the number of workers.
This rate limit may not be reachable unless there is sufficient parallelism.
A rate of <= 0.0 disables rate limiting.
public RateLimiting.RateLimitingTransform<I,O> withMaxParallelism(int max)
RateLimitingTransform, specifying a maximum
per-worker parallelism.
This determines how many concurrent elements will be processed by the
wrapped DoFn.
The desired amount of parallelism depends upon the type of work. For
CPU-intensive work, a good starting point is to use the number of cores:
Runtime.getRuntime().availableProcessors().
public PCollection<O> apply(PCollection<? extends I> input)
PTransformPTransform on the given Input, and returns its
Output.
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).
The default implementation throws an exception. A derived class must
either implement apply, or else each runner must supply a custom
implementation via
PipelineRunner.apply(com.google.cloud.dataflow.sdk.transforms.PTransform<Input, Output>, Input).
apply in class PTransform<PCollection<? extends I>,PCollection<O>>