Class IterableSink<T>

java.lang.Object
org.voltdb.stream.sink.IterableSink<T>
Type Parameters:
T - the type of elements consumed by this sink
All Implemented Interfaces:
Consumer<T>, VoltLifecycle, VoltStreamSink<T>

public class IterableSink<T> extends Object implements VoltStreamSink<T>
Captures all stream items into a list.

This sink is primarily used for testing or scenarios where in-memory storage of streamed data is sufficient. Use only on bounded streams otherwise out of memory error will occur.

  • Constructor Details

    • IterableSink

      public IterableSink()
  • Method Details

    • consume

      public void consume(T output)
      Description copied from interface: Consumer
      This method is invoked by any upstream caller, the caller can emmit any number of events to a consumer.
      Specified by:
      consume in interface Consumer<T>
      Parameters:
      output - event
    • copy

      public List<T> copy()
      Creates and returns a copy of the current contents of the sink.

      This method provides a snapshot of all data items that have been consumed up to the point of invocation. Modifications to the returned list do not affect the internal sink.

      Returns:
      a new List containing all elements consumed by this sink
    • clear

      public void clear()
      Clears all data items from the internal sink.

      After calling this method, the sink will be empty, and subsequent calls to copy() will return an empty list until new items are consumed.