Class IterableSource<T>

java.lang.Object
org.voltdb.stream.source.GeneratorSource<T>
org.voltdb.stream.source.IterableSource<T>
Type Parameters:
T - the type of elements produced by this source.
All Implemented Interfaces:
VoltLifecycle, VoltStreamSource<T>

public class IterableSource<T> extends GeneratorSource<T>
Generates a stream of data items from an Iterable.

Does not try to modify passed iterable. The iterable does not have to be thread safe. The user should assume it is not copied therefore should not modify it externally.

  • Method Details

    • from

      public static <T> VoltStreamSource<T> from(Collection<T> given)
      Creates a source from the given Collection.
      Type Parameters:
      T - the type of elements in the collection
      Parameters:
      given - the collection of elements to be streamed
      Returns:
      a new instance of IterableSource containing the provided collection
    • iterate

      @SafeVarargs public static <T> VoltStreamSource<T> iterate(T... given)
      Creates a source from the provided elements.
      Type Parameters:
      T - the type of elements
      Parameters:
      given - the elements to be streamed
      Returns:
      a new instance of IterableSource containing the provided elements
    • range

      public static VoltStreamSource<Integer> range(int start, int end)
      Creates a source that generates a range of integers from start (inclusive) to end (exclusive).
      Parameters:
      start - the starting integer of the range (inclusive)
      end - the ending integer of the range (exclusive)
      Returns:
      a new instance of IterableSource containing the specified range of integers
    • next

      protected T next()
      Description copied from class: GeneratorSource
      Implementation should generate the next item in the stream.
      Specified by:
      next in class GeneratorSource<T>
      Returns:
      the next item of type T
    • hasNext

      protected boolean hasNext()
      Description copied from class: GeneratorSource
      A way for the implementation to indicate wheter there are more items to generate in the stream.
      Specified by:
      hasNext in class GeneratorSource<T>
      Returns:
      true if there are more items to generate, false otherwise