Class FormatModelRegistry
This registry provides access to ReadBuilders for data consumption and FileWriterBuilders for writing various types of Iceberg content files. The appropriate builder
is selected based on FileFormat and object model class.
FormatModel objects are registered through register(FormatModel) and used for
creating readers and writers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <D,S> FileWriterBuilder <DataWriter<D>, S> dataWriteBuilder(FileFormat format, Class<? extends D> type, EncryptedOutputFile outputFile) Returns a writer builder for generating aDataFile.static <D,S> FileWriterBuilder <EqualityDeleteWriter<D>, S> equalityDeleteWriteBuilder(FileFormat format, Class<D> type, EncryptedOutputFile outputFile) Creates a writer builder for generating aDeleteFilewith equality deletes.static <D> FileWriterBuilder<PositionDeleteWriter<D>, ?> positionDeleteWriteBuilder(FileFormat format, EncryptedOutputFile outputFile) Creates a writer builder for generating aDeleteFilewith position-based deletes.static <D,S> ReadBuilder <D, S> readBuilder(FileFormat format, Class<? extends D> type, InputFile inputFile) Returns a reader builder for the specified file format and object model.static voidregister(FormatModel<?, ?> formatModel) Registers anFormatModelin this registry.
-
Method Details
-
register
Registers anFormatModelin this registry.The
FormatModelcreates readers and writers for a specific combinations of file format (Parquet, ORC, Avro) and object model (for example: "generic", "spark", "flink", etc.). Registering custom factories allows integration of new data processing engines for the supported file formats with Iceberg's file access mechanisms.Each factory must be uniquely identified by its combination of file format and object model name. This uniqueness constraint prevents ambiguity when selecting factories for read and write operations.
- Parameters:
formatModel- the factory implementation to register- Throws:
IllegalArgumentException- if a factory is already registered for the combination ofFormatModel.format()andFormatModel.type()
-
readBuilder
public static <D,S> ReadBuilder<D,S> readBuilder(FileFormat format, Class<? extends D> type, InputFile inputFile) Returns a reader builder for the specified file format and object model.The returned
ReadBuilderprovides a fluent interface for configuring how data is read from the input file and converted to the output objects.- Type Parameters:
D- the type of data records the reader will produceS- the type of the output schema for the reader- Parameters:
format- the file format (Parquet, Avro, ORC) that determines the parsing implementationtype- the output typeinputFile- source file to read data from- Returns:
- a configured reader builder for the specified format and object model
-
dataWriteBuilder
public static <D,S> FileWriterBuilder<DataWriter<D>,S> dataWriteBuilder(FileFormat format, Class<? extends D> type, EncryptedOutputFile outputFile) Returns a writer builder for generating aDataFile.The returned builder produces a writer that accepts records defined by the specified object model and persists them using the provided file format. Unlike basic writers, this writer collects file metadata during the writing process and generates a
DataFilethat can be used for table operations.- Type Parameters:
D- the type of data records the writer will acceptS- the type of the input schema for the writer- Parameters:
format- the file format used for writingtype- the input typeoutputFile- destination for the written data- Returns:
- a configured data write builder for creating a
DataWriter
-
equalityDeleteWriteBuilder
public static <D,S> FileWriterBuilder<EqualityDeleteWriter<D>,S> equalityDeleteWriteBuilder(FileFormat format, Class<D> type, EncryptedOutputFile outputFile) Creates a writer builder for generating aDeleteFilewith equality deletes.The returned builder produces a writer that accepts records defined by the specified object model and persists them using the given file format. The writer persists equality delete records that identify rows to be deleted based on the configured equality fields, producing a
DeleteFilethat can be used for table operations.- Type Parameters:
D- the type of data records the writer will acceptS- the type of the input schema for the writer- Parameters:
format- the file format used for writingtype- the input typeoutputFile- destination for the written data- Returns:
- a configured delete write builder for creating an
EqualityDeleteWriter
-
positionDeleteWriteBuilder
public static <D> FileWriterBuilder<PositionDeleteWriter<D>,?> positionDeleteWriteBuilder(FileFormat format, EncryptedOutputFile outputFile) Creates a writer builder for generating aDeleteFilewith position-based deletes.The returned builder produces a writer that accepts records defined by the specified object model and persists them using the given file format. The writer accepts
PositionDeleterecords that identify rows to be deleted by file path and position, producing aDeleteFilethat can be used for table operations.Note: This method is only applicable to format-version 2 tables. Format-version 3 tables use deletion vectors, which are always written in Puffin format. Registered
FormatModelimplementations forPositionDeleteare not consulted for format-version 3+ tables.- Parameters:
format- the file format used for writingoutputFile- destination for the written data- Returns:
- a configured delete write builder for creating a
PositionDeleteWriter
-