pvary commented on code in PR #12774: URL: https://github.com/apache/iceberg/pull/12774#discussion_r2095462749
########## core/src/main/java/org/apache/iceberg/io/ObjectModel.java: ########## @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.io; + +import org.apache.iceberg.FileFormat; + +/** + * Direct conversion is used between file formats and engine internal formats for performance + * reasons. Object models encapsulate these conversions. + * + * <p>{@link ReadBuilder} is provided for reading data files stored in a given {@link FileFormat} + * into the engine specific object model. + * + * <p>{@link AppenderBuilder} is provided for writing engine specific object model to data/delete + * files stored in a given {@link FileFormat}. + * + * <p>Iceberg supports the following object models natively: + * + * <ul> + * <li>generic - reads and writes Iceberg {@link org.apache.iceberg.data.Record}s + * <li>spark - reads and writes Spark InternalRow records + * <li>spark-vectorized - vectorized reads for Spark columnar batches. Not supported for {@link + * FileFormat#AVRO} + * <li>flink - reads and writes Flink RowData records + * <li>arrow - vectorized reads for into Arrow columnar format. Only supported for {@link + * FileFormat#PARQUET} + * </ul> + * + * <p>Engines could implement their own object models to leverage Iceberg data file reading and + * writing capabilities. + * + * @param <E> the engine specific schema of the input data for the appender + */ +public interface ObjectModel<E> { + /** The file format which is read/written by the object model. */ + FileFormat format(); + + /** + * The name of the object model. Allows users to specify the object model to map the data file for + * reading and writing. + */ + String name(); + + /** + * The appender builder for the output file which writes the data in the specified file format and + * accepts the records defined by this object model. The 'mode' parameter defines the input type + * for the specific writer use-cases. The appender should handle the following input in the + * specific modes: + * + * <ul> + * <li>The appender's engine specific input type + * <ul> + * <li>{@link WriteMode#DATA_WRITER} + * <li>{@link WriteMode#EQUALITY_DELETE_WRITER} + * </ul> + * <li>{@link org.apache.iceberg.deletes.PositionDelete} where the type of the row is the + * appender's engine specific input type when the 'mode' is {@link + * WriteMode#POSITION_DELETE_WRITER} + * </ul> + * + * @param outputFile to write to + * @param mode for the appender + * @return the appender builder + * @param <B> The type of the appender builder + */ + <B extends AppenderBuilder<B, E>> B appenderBuilder(OutputFile outputFile, WriteMode mode); Review Comment: Went ahead and used `FileContent`. About the 3 different method approach: - We would like to expose the same Appender interface for Flink (or other users) that it is provided by the File Format. There we don't want any mention of "FileContent" or "WriteMode" or multiple builder methods. That is why I opted for passing the mode in the constructor. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org