Class StdoutSink<T>

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

public class StdoutSink<T> extends Object implements VoltStreamSink<T>
A sink that writes streamed data items to the standard output (console).

This sink encodes each data item using a provided encoder function and appends a newline character after each encoded item. It is primarily used for debugging, logging, or scenarios where immediate visibility of streamed data is useful.

  • Constructor Details

    • StdoutSink

      public StdoutSink(Function<T,CharSequence> encoder)
      Constructs a StdoutSink with the specified encoder function.

      The encoder function defines how each consumed data item is transformed into a CharSequence before being written to the standard output.

      The memory backing CharSequence returned by the encoder can be reused for subsequent encodings.

      Parameters:
      encoder - a function that converts each input item to a CharSequence for writing to the console
  • Method Details

    • toStringSink

      public static StdoutSink<Object> toStringSink()
      Creates a StdoutSink that converts each consumed object to its string representation.
      Returns:
      a new instance of StdoutSink using Objects::toString as the encoder
    • commit

      public CommitResult commit(ExecutionContext context)
      Description copied from interface: VoltStreamSink
      the callback is invoked when the sink has to perform any logic assuring data is securely passed to downstream system
      Specified by:
      commit in interface VoltStreamSink<T>
      Parameters:
      context - runtime context
      Returns:
      result of the commit
    • 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