public class NumberSequenceSource extends Object implements Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>, ResultTypeQueryable<Long>
The source splits the sequence into as many parallel sub-sequences as there are parallel source readers. Each sub-sequence will be produced in order. Consequently, if the parallelism is limited to one, this will produce one sequence in order.
This source is always bounded. For very long sequences (for example over the entire domain of long integer values), user may want to consider executing the application in a streaming manner, because, despite the fact that the produced stream is bounded, the end bound is pretty far away.
Modifier and Type | Class and Description |
---|---|
static class |
NumberSequenceSource.NumberSequenceSplit
A split of the source, representing a number sub-sequence.
|
Constructor and Description |
---|
NumberSequenceSource(long from,
long to)
Creates a new
NumberSequenceSource that produces parallel sequences covering the
range from to to (both boundaries are inclusive). |
public NumberSequenceSource(long from, long to)
NumberSequenceSource
that produces parallel sequences covering the
range from
to to
(both boundaries are inclusive).public TypeInformation<Long> getProducedType()
ResultTypeQueryable
TypeInformation
) produced by this function or input format.getProducedType
in interface ResultTypeQueryable<Long>
public Boundedness getBoundedness()
Source
getBoundedness
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
public SourceReader<Long,NumberSequenceSource.NumberSequenceSplit> createReader(SourceReaderContext readerContext)
Source
createReader
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
readerContext
- The context
for the source reader.public SplitEnumerator<NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>> createEnumerator(SplitEnumeratorContext<NumberSequenceSource.NumberSequenceSplit> enumContext)
Source
createEnumerator
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
enumContext
- The context
for the split enumerator.public SplitEnumerator<NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>> restoreEnumerator(SplitEnumeratorContext<NumberSequenceSource.NumberSequenceSplit> enumContext, Collection<NumberSequenceSource.NumberSequenceSplit> checkpoint)
Source
restoreEnumerator
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
enumContext
- The context
for the restored split
enumerator.checkpoint
- The checkpoint to restore the SplitEnumerator from.public SimpleVersionedSerializer<NumberSequenceSource.NumberSequenceSplit> getSplitSerializer()
Source
getSplitSerializer
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
public SimpleVersionedSerializer<Collection<NumberSequenceSource.NumberSequenceSplit>> getEnumeratorCheckpointSerializer()
Source
SplitEnumerator
checkpoint. The serializer is used for
the result of the SplitEnumerator.snapshotState()
method.getEnumeratorCheckpointSerializer
in interface Source<Long,NumberSequenceSource.NumberSequenceSplit,Collection<NumberSequenceSource.NumberSequenceSplit>>
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.