Class CountingSource
GenerateSequence instead.
A source that produces longs. When used as a BoundedSource, CountingSource
starts at 0 and counts up to a specified maximum. When used as an UnboundedSource, it counts up to Long.MAX_VALUE and then never produces more output. (In
practice, this limit should never be reached.)
The bounded CountingSource is implemented based on OffsetBasedSource and
OffsetBasedSource.OffsetBasedReader, so it performs efficient initial splitting and it
supports dynamic work rebalancing.
To produce a bounded source, use createSourceForSubrange(long, long). To produce an
unbounded source, use createUnboundedFrom(long).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe checkpoint for an unboundedCountingSourceis simply the last value produced.static classA custom coder forCounterMark. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.unboundedWithTimestampFn(SerializableFunction<Long, Instant> timestampFn) Deprecated.useGenerateSequenceand callGenerateSequence.withTimestampFn(SerializableFunction)insteadstatic BoundedSource<Long> upTo(long numElements) Deprecated.useGenerateSequenceinstead
-
Method Details
-
upTo
Deprecated.useGenerateSequenceinsteadCreates aBoundedSourcethat will produce the specified number of elements, from0tonumElements - 1. -
unbounded
Deprecated.useGenerateSequenceinsteadCreates anUnboundedSourcethat will produce numbers starting from0up toLong.MAX_VALUE.After
Long.MAX_VALUE, the source never produces more output. (In practice, this limit should never be reached.)Elements in the resulting
PCollection<Long>will have timestamps corresponding to processing time at element generation, provided byInstant.now(). -
unboundedWithTimestampFn
@Deprecated public static UnboundedSource<Long,CountingSource.CounterMark> unboundedWithTimestampFn(SerializableFunction<Long, Instant> timestampFn) Deprecated.useGenerateSequenceand callGenerateSequence.withTimestampFn(SerializableFunction)insteadCreates anUnboundedSourcethat will produce numbers starting from0up toLong.MAX_VALUE, with element timestamps supplied by the specified function.After
Long.MAX_VALUE, the source never produces more output. (In practice, this limit should never be reached.)Note that the timestamps produced by
timestampFnmay not decrease.
-
GenerateSequenceinstead