Class SequenceGenerator<T>

java.lang.Object
org.apache.flink.streaming.api.functions.source.datagen.SequenceGenerator<T>
All Implemented Interfaces:
Serializable, Iterator<T>, DataGenerator<T>

@Experimental public abstract class SequenceGenerator<T> extends Object implements DataGenerator<T>
A stateful, re-scalable DataGenerator that emits each number from a given interval exactly once, possibly in parallel.
See Also:
  • Field Details

    • valuesToEmit

      protected transient Deque<Long> valuesToEmit
  • Constructor Details

    • SequenceGenerator

      public SequenceGenerator(long start, long end)
      Creates a DataGenerator that emits all numbers from the given interval exactly once.
      Parameters:
      start - Start of the range of numbers to emit.
      end - End of the range of numbers to emit.
  • Method Details

    • open

      public void open(String name, org.apache.flink.runtime.state.FunctionInitializationContext context, org.apache.flink.api.common.functions.RuntimeContext runtimeContext) throws Exception
      Description copied from interface: DataGenerator
      Open and initialize state for DataGenerator. See CheckpointedFunction.initializeState(org.apache.flink.runtime.state.FunctionInitializationContext).
      Specified by:
      open in interface DataGenerator<T>
      Parameters:
      name - The state of DataGenerator should related to this name, make sure the name of state is different.
      Throws:
      Exception
    • snapshotState

      public void snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) throws Exception
      Description copied from interface: DataGenerator
      Snapshot state for DataGenerator. See CheckpointedFunction.snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext).
      Specified by:
      snapshotState in interface DataGenerator<T>
      Throws:
      Exception
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<T>
    • longGenerator

      public static SequenceGenerator<Long> longGenerator(long start, long end)
    • intGenerator

      public static SequenceGenerator<Integer> intGenerator(int start, int end)
    • shortGenerator

      public static SequenceGenerator<Short> shortGenerator(short start, short end)
    • byteGenerator

      public static SequenceGenerator<Byte> byteGenerator(byte start, byte end)
    • floatGenerator

      public static SequenceGenerator<Float> floatGenerator(short start, short end)
    • doubleGenerator

      public static SequenceGenerator<Double> doubleGenerator(int start, int end)
    • bigDecimalGenerator

      public static SequenceGenerator<BigDecimal> bigDecimalGenerator(int start, int end, int precision, int scale)
    • stringGenerator

      public static SequenceGenerator<String> stringGenerator(long start, long end)