T - record type.R - file result to collect.public interface FileWriter<T,R> extends Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort to clear orphan file(s) if encounter any error.
|
long |
recordCount()
The total written record count.
|
R |
result() |
default void |
write(CloseableIterator<T> records)
Add records from
CloseableIterator to this file writer. |
default void |
write(Iterable<T> records)
Add records from
Iterable to file writer. |
default void |
write(Iterator<T> records)
Add records from
Iterator to this file writer. |
void |
write(T record)
Add only one record to this file writer.
|
void write(T record) throws IOException
NOTE: If any exception occurs during writing, the writer should clean up useless files for the user.
record - to write.IOException - if encounter any IO error.default void write(Iterator<T> records) throws Exception
Iterator to this file writer.
NOTE: If any exception occurs during writing, the writer should clean up useless files for the user.
records - to writeIOException - if encounter any IO error.Exceptiondefault void write(CloseableIterator<T> records) throws Exception
CloseableIterator to this file writer.
NOTE: If any exception occurs during writing, the writer should clean up useless files for the user.
records - to writeIOException - if encounter any IO error.Exceptiondefault void write(Iterable<T> records) throws IOException
Iterable to file writer.
NOTE: If any exception occurs during writing, the writer should clean up useless files for the user.
records - to write.IOException - if encounter any IO error.long recordCount()
void abort()
NOTE: This implementation must be reentrant.
R result() throws IOException
IOExceptionCopyright © 2023–2024 The Apache Software Foundation. All rights reserved.