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, wait
write, write, write
public RollingFileWriter(java.util.function.Supplier<? extends SingleFileWriter<T,R>> writerFactory, long targetFileSize)
@VisibleForTesting public long targetFileSize()
public void write(T row) throws IOException
FileWriter
NOTE: 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
IOException
public long recordCount()
FileWriter
recordCount
in interface FileWriter<T,List<R>>
public void abort()
FileWriter
NOTE: 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 Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.