Class SortingPositionOnlyDeleteWriter<T>
- java.lang.Object
-
- org.apache.iceberg.deletes.SortingPositionOnlyDeleteWriter<T>
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,FileWriter<PositionDelete<T>,DeleteWriteResult>
public class SortingPositionOnlyDeleteWriter<T> extends java.lang.Object implements FileWriter<PositionDelete<T>,DeleteWriteResult>
A position delete writer that is capable of handling unordered deletes without rows.This writer keeps an in-memory bitmap of deleted positions per each seen data file and flushes the result into a file when closed. This enables writing position delete files when the incoming records are not ordered by file and position as required by the spec. If the incoming deletes are ordered by an external process, use
PositionDeleteWriter
instead.If configured, this writer can also load previous deletes using the provided function and merge them with incoming ones prior to flushing the deletes into a file. Callers must ensure only previous file-scoped deletes are loaded because partition-scoped deletes can apply to multiple data files and can't be safely discarded.
Note this writer stores only positions. It does not store deleted records.
-
-
Constructor Summary
Constructors Constructor Description SortingPositionOnlyDeleteWriter(java.util.function.Supplier<FileWriter<PositionDelete<T>,DeleteWriteResult>> writers, DeleteGranularity granularity)
SortingPositionOnlyDeleteWriter(java.util.function.Supplier<FileWriter<PositionDelete<T>,DeleteWriteResult>> writers, DeleteGranularity granularity, java.util.function.Function<java.lang.CharSequence,PositionDeleteIndex> loadPreviousDeletes)
SortingPositionOnlyDeleteWriter(FileWriter<PositionDelete<T>,DeleteWriteResult> writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
long
length()
Returns the number of bytes that were currently written by this writer.DeleteWriteResult
result()
Returns a result that contains information about writtenDataFile
s orDeleteFile
s.void
write(PositionDelete<T> positionDelete)
Writes a row to a predefined spec/partition.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.io.FileWriter
write
-
-
-
-
Constructor Detail
-
SortingPositionOnlyDeleteWriter
public SortingPositionOnlyDeleteWriter(FileWriter<PositionDelete<T>,DeleteWriteResult> writer)
-
SortingPositionOnlyDeleteWriter
public SortingPositionOnlyDeleteWriter(java.util.function.Supplier<FileWriter<PositionDelete<T>,DeleteWriteResult>> writers, DeleteGranularity granularity)
-
SortingPositionOnlyDeleteWriter
public SortingPositionOnlyDeleteWriter(java.util.function.Supplier<FileWriter<PositionDelete<T>,DeleteWriteResult>> writers, DeleteGranularity granularity, java.util.function.Function<java.lang.CharSequence,PositionDeleteIndex> loadPreviousDeletes)
-
-
Method Detail
-
write
public void write(PositionDelete<T> positionDelete)
Description copied from interface:FileWriter
Writes a row to a predefined spec/partition.- Specified by:
write
in interfaceFileWriter<PositionDelete<T>,DeleteWriteResult>
- Parameters:
positionDelete
- a data or delete record
-
length
public long length()
Description copied from interface:FileWriter
Returns the number of bytes that were currently written by this writer.- Specified by:
length
in interfaceFileWriter<PositionDelete<T>,DeleteWriteResult>
- Returns:
- the number of written bytes
-
result
public DeleteWriteResult result()
Description copied from interface:FileWriter
Returns a result that contains information about writtenDataFile
s orDeleteFile
s. The result is valid only after the writer is closed.- Specified by:
result
in interfaceFileWriter<PositionDelete<T>,DeleteWriteResult>
- Returns:
- the file writer result
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-