Package org.apache.iceberg.io
Class BufferedFileAppender<D>
java.lang.Object
org.apache.iceberg.io.BufferedFileAppender<D>
- Type Parameters:
D- the row type
- All Implemented Interfaces:
Closeable,AutoCloseable,FileAppender<D>
A FileAppender that buffers the first N rows, then creates a delegate appender via a factory.
The factory receives the buffered rows and is responsible for creating the real appender. Row
replay is handled internally. All subsequent add(D) calls delegate directly to the real
appender.
If fewer than bufferSize rows are written before close, the factory is called with
whatever rows were buffered. If no rows were written, the factory is not called and no file is
created on disk. In this case, metrics() returns new Metrics(0L) and length() returns 0L.
-
Constructor Summary
ConstructorsConstructorDescriptionBufferedFileAppender(int bufferRowCount, Function<List<D>, FileAppender<D>> appenderFactory) BufferedFileAppender(int bufferRowCount, Function<List<D>, FileAppender<D>> appenderFactory, UnaryOperator<D> copyFunc) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.iceberg.io.FileAppender
addAll, addAll
-
Constructor Details
-
BufferedFileAppender
- Parameters:
bufferRowCount- number of rows to buffer before creating the delegate appenderappenderFactory- given the buffered rows, creates the delegate appender
-
BufferedFileAppender
public BufferedFileAppender(int bufferRowCount, Function<List<D>, FileAppender<D>> appenderFactory, UnaryOperator<D> copyFunc) - Parameters:
bufferRowCount- number of rows to buffer before creating the delegate appenderappenderFactory- given the buffered rows, creates the delegate appendercopyFunc- copies a row before buffering (needed when row objects are reused, e.g. Spark InternalRow)
-
-
Method Details
-
add
- Specified by:
addin interfaceFileAppender<D>
-
metrics
Description copied from interface:FileAppenderReturnsMetricsfor this file. Only valid after the file is closed.- Specified by:
metricsin interfaceFileAppender<D>
-
length
public long length()Description copied from interface:FileAppenderReturns the length of this file.- Specified by:
lengthin interfaceFileAppender<D>
-
splitOffsets
Description copied from interface:FileAppenderReturns a list of recommended split locations, if applicable, null otherwise.When available, this information is used for planning scan tasks whose boundaries are determined by these offsets. The returned list must be sorted in ascending order. Only valid after the file is closed.
- Specified by:
splitOffsetsin interfaceFileAppender<D>
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-