T - record data type.R - the file metadata result.public class RollingFileWriter<T,R> extends Object implements FileWriter<T,List<R>>
| Constructor and Description |
|---|
RollingFileWriter(java.util.function.Supplier<? extends SingleFileWriter<T,R>> writerFactory,
long targetFileSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort to clear orphan file(s) if encounter any error.
|
void |
close() |
long |
recordCount()
The total written record count.
|
List<R> |
result() |
long |
targetFileSize() |
void |
write(T row)
Add only one record to this file writer.
|
void |
writeBundle(BundleRecords bundle) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwrite, write, writepublic RollingFileWriter(java.util.function.Supplier<? extends SingleFileWriter<T,R>> writerFactory, long targetFileSize)
@VisibleForTesting public long targetFileSize()
public void write(T row) throws IOException
FileWriterNOTE: If any exception occurs during writing, the writer should clean up useless files for the user.
write in interface FileWriter<T,List<R>>row - to write.IOException - if encounter any IO error.public void writeBundle(BundleRecords bundle) throws IOException
IOExceptionpublic long recordCount()
FileWriterrecordCount in interface FileWriter<T,List<R>>public void abort()
FileWriterNOTE: This implementation must be reentrant.
abort in interface FileWriter<T,List<R>>public List<R> result()
result in interface FileWriter<T,List<R>>public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2023–2024 The Apache Software Foundation. All rights reserved.