Package org.voltdb.stream.sink
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>
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 Summary
ConstructorDescriptionStdoutSink
(Function<T, CharSequence> encoder) Constructs aStdoutSink
with the specified encoder function. -
Method Summary
Modifier and TypeMethodDescriptioncommit
(ExecutionContext context) the callback is invoked when the sink has to perform any logic assuring data is securely passed to downstream systemvoid
This method is invoked by any upstream caller, the caller can emmit any number of events to a consumer.static StdoutSink
<Object> Creates aStdoutSink
that converts each consumed object to its string representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.voltdb.stream.api.pipeline.VoltLifecycle
configure, destroy
Methods inherited from interface org.voltdb.stream.api.pipeline.VoltStreamSink
batchProcessed, nextBatchStarts
-
Constructor Details
-
StdoutSink
Constructs aStdoutSink
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 aCharSequence
for writing to the console
-
-
Method Details
-
toStringSink
Creates aStdoutSink
that converts each consumed object to its string representation.- Returns:
- a new instance of
StdoutSink
usingObjects::toString
as the encoder
-
commit
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 interfaceVoltStreamSink<T>
- Parameters:
context
- runtime context- Returns:
- result of the commit
-
consume
Description copied from interface:Consumer
This method is invoked by any upstream caller, the caller can emmit any number of events to a consumer.
-