Interface Writer<T>
- All Superinterfaces:
DataRecordsWriter<T>, DataWriter<T>
Writer interface used by SBK drivers to provide asynchronous write semantics.
This interface extends DataRecordsWriter and provides a simple
asynchronous writeAsync(Object) primitive plus convenience default
implementations that attach timing metadata and report metrics. Implementors
should override the asynchronous primitive and may rely on the default
helpers for common harness behaviour.
Guidelines for implementors:
- Implement
writeAsync(Object)to perform a non-blocking write and return aCompletableFuturethat completes when the write is accepted/committed. Returningnullfrom higher-level helpers is used to indicate synchronous completion. - Override
sync()if your storage requires an explicit flush or durability call after batches of writes. - Prefer the
writeSetTimehelpers when you need the harness to embed a start timestamp into the payload for end-to-end latency measurement.
Original short description preserved:
Interface for Writers.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the Writer.default voidrecordWrite(DataType<T> dType, T data, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel) Default implementation for writing data usingwrite(DataType, Object, int, Time, Status)and recording the benchmark statistics.default voidrecordWrite(DataType<T> dType, T data, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel, int id, WriteRequestsLogger logger) Default implementation for writing data usingwrite(DataType, Object, int, Time, Status)and recording the benchmark statistics.default voidsync()Flush / Sync the data.default CompletableFuture<?> Default implementation for writing data usingwriteAsync(Object))} with start time.default CompletableFuture<?> write(DataType<T> dType, T data, int size, io.time.Time time, Status status, int id, WriteRequestsLogger logger) Default implementation for writing data usingwriteAsync(Object))} with start time.writeAsync(T data) Asynchronously Writes the data .default voidwriteSetTime(DataType<T> dType, T data, int size, io.time.Time time, Status status) Default implementation for writing data usingwriteAsync(Object)with start time If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method.default voidwriteSetTime(DataType<T> dType, T data, int size, io.time.Time time, Status status, int id, WriteRequestsLogger logger) Default implementation for writing data usingwriteAsync(Object)with start time If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method.Methods inherited from interface DataRecordsWriter
RecordsWriter, RecordsWriter, RecordsWriterRO, RecordsWriterRO, RecordsWriterRW, RecordsWriterRW, RecordsWriterSync, RecordsWriterSync, RecordsWriterTime, RecordsWriterTime, RecordsWriterTimeRO, RecordsWriterTimeRO, RecordsWriterTimeRW, RecordsWriterTimeRW, RecordsWriterTimeSync, RecordsWriterTimeSync
-
Method Details
-
writeAsync
Asynchronously Writes the data .- Parameters:
data- data to write- Returns:
- CompletableFuture completable future. null if write completed synchronously .
- Throws:
IOException- If an exception occurred.
-
close
Close the Writer.- Specified by:
closein interfaceDataWriter<T>- Throws:
IOException- If an exception occurred.
-
sync
Flush / Sync the data.- Specified by:
syncin interfaceDataRecordsWriter<T>- Throws:
IOException- If an exception occurred.
-
write
default CompletableFuture<?> write(DataType<T> dType, T data, int size, io.time.Time time, Status status) throws IOException Default implementation for writing data usingwriteAsync(Object))} with start time. If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
writein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writersize- size of the datatime- time interfacestatus- write status to return- Returns:
- CompletableFuture completable future. null if write completed synchronously .
- Throws:
IOException- If an exception occurred.
-
write
default CompletableFuture<?> write(DataType<T> dType, T data, int size, io.time.Time time, Status status, int id, WriteRequestsLogger logger) throws IOException Default implementation for writing data usingwriteAsync(Object))} with start time. If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
writein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writersize- size of the datatime- time interfacestatus- write status to returnid- Writer idlogger- log writer requests- Returns:
- CompletableFuture completable future. null if write completed synchronously .
- Throws:
IOException- If an exception occurred.
-
writeSetTime
default void writeSetTime(DataType<T> dType, T data, int size, io.time.Time time, Status status) throws IOException Default implementation for writing data usingwriteAsync(Object)with start time If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
writeSetTimein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writersize- size of the datatime- time interfacestatus- write status to return- Throws:
IOException- If an exception occurred.
-
writeSetTime
default void writeSetTime(DataType<T> dType, T data, int size, io.time.Time time, Status status, int id, WriteRequestsLogger logger) throws IOException Default implementation for writing data usingwriteAsync(Object)with start time If you are intend to NOT use the CompletableFuture returned bywriteAsync(Object))} then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
writeSetTimein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writersize- size of the datatime- time interfacestatus- write status to returnid- Writer idlogger- log writer requests- Throws:
IOException- If an exception occurred.
-
recordWrite
default void recordWrite(DataType<T> dType, T data, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel) throws IOException Default implementation for writing data usingwrite(DataType, Object, int, Time, Status)and recording the benchmark statistics. If you are intend to NOT use the CompletableFuture returned bywrite(DataType, Object, int, Time, Status)then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
recordWritein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writesize- size of the datatime- time interfacestatus- Write status to returnperlChannel- to call for benchmarking- Throws:
IOException- If an exception occurred.
-
recordWrite
default void recordWrite(DataType<T> dType, T data, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel, int id, WriteRequestsLogger logger) throws IOException Default implementation for writing data usingwrite(DataType, Object, int, Time, Status)and recording the benchmark statistics. If you are intend to NOT use the CompletableFuture returned bywrite(DataType, Object, int, Time, Status)then you can override this method. otherwise, use the default implementation and don't override this method. If you are intend to use your own payload, then also you can use override this method. you can write multiple records with this method.- Specified by:
recordWritein interfaceDataRecordsWriter<T>- Parameters:
dType- Data Type interfacedata- data to writesize- size of the datatime- time interfacestatus- Write status to returnperlChannel- to call for benchmarkingid- Writer idlogger- log writer requests- Throws:
IOException- If an exception occurred.
-