Package org.voltdb.stream.sink
Class FileSink<T>
java.lang.Object
org.voltdb.stream.sink.FileSink<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 a file within a specified directory.
Each instance of FileSink
creates a new file with a unique name in the designated directory.
Data items are encoded into bytes and written to the file, each separated by a specified line terminator.
-
Constructor Summary
-
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
configure
(ExecutionContext context) void
This method is invoked by any upstream caller, the caller can emmit any number of events to a consumer.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
destroy
Methods inherited from interface org.voltdb.stream.api.pipeline.VoltStreamSink
batchProcessed, nextBatchStarts
-
Constructor Details
-
FileSink
Constructs aFileSink
with the specified directory path.Uses the system's default line separator and a default encoder that converts each input to its string representation in the platform's default charset.
- Parameters:
directoryPath
- the path to the directory where output files will be created
-
FileSink
Constructs aFileSink
with the specified directory path, line terminator, and encoder.This constructor allows customization of the line terminator and the encoding mechanism for input data.
- Parameters:
directoryPath
- the path to the directory where output files will be createdlineTerminator
- the string to append after each encoded data item (e.g., newline)encoder
- a function that converts each input item to a byte array for writing to the file
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceVoltLifecycle
-
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. -
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
-