T
- type of records to write.R
- type of result to produce after writing a file.public abstract class SingleFileWriter<T,R> extends Object implements FileWriter<T,R>
FileWriter
to produce a single file.Modifier and Type | Class and Description |
---|---|
static class |
SingleFileWriter.AbortExecutor
Abort executor to just have reference of path instead of whole writer.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected FileIO |
fileIO |
protected Path |
path |
Constructor and Description |
---|
SingleFileWriter(FileIO fileIO,
FormatWriterFactory factory,
Path path,
java.util.function.Function<T,InternalRow> converter,
String compression,
boolean asyncWrite) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort to clear orphan file(s) if encounter any error.
|
SingleFileWriter.AbortExecutor |
abortExecutor() |
void |
close() |
Path |
path() |
boolean |
reachTargetSize(boolean suggestedCheck,
long targetSize) |
long |
recordCount()
The total written record count.
|
void |
write(T record)
Add only one record to this file writer.
|
void |
writeBundle(BundleRecords bundle) |
protected InternalRow |
writeImpl(T record) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
result, write, write, write
protected final FileIO fileIO
protected final Path path
protected boolean closed
public SingleFileWriter(FileIO fileIO, FormatWriterFactory factory, Path path, java.util.function.Function<T,InternalRow> converter, String compression, boolean asyncWrite)
public Path path()
public void write(T record) 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,R>
record
- to write.IOException
- if encounter any IO error.public void writeBundle(BundleRecords bundle) throws IOException
IOException
protected InternalRow writeImpl(T record) throws IOException
IOException
public long recordCount()
FileWriter
recordCount
in interface FileWriter<T,R>
public boolean reachTargetSize(boolean suggestedCheck, long targetSize) throws IOException
IOException
public void abort()
FileWriter
NOTE: This implementation must be reentrant.
abort
in interface FileWriter<T,R>
public SingleFileWriter.AbortExecutor abortExecutor()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.