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 class
The checkpoint for an unboundedCountingSource
is simply the last value produced.static class
A custom coder forCounterMark
. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.unboundedWithTimestampFn
(SerializableFunction<Long, Instant> timestampFn) Deprecated.useGenerateSequence
and callGenerateSequence.withTimestampFn(SerializableFunction)
insteadstatic BoundedSource
<Long> upTo
(long numElements) Deprecated.useGenerateSequence
instead
-
Method Details
-
upTo
Deprecated.useGenerateSequence
insteadCreates aBoundedSource
that will produce the specified number of elements, from0
tonumElements - 1
. -
unbounded
Deprecated.useGenerateSequence
insteadCreates anUnboundedSource
that will produce numbers starting from0
up 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.useGenerateSequence
and callGenerateSequence.withTimestampFn(SerializableFunction)
insteadCreates anUnboundedSource
that will produce numbers starting from0
up 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
timestampFn
may not decrease.
-
GenerateSequence
instead