pvary commented on code in PR #12298:
URL: https://github.com/apache/iceberg/pull/12298#discussion_r2602186946


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetFormatModel.java:
##########
@@ -0,0 +1,394 @@
+/*
+ * 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.parquet;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.function.Function;
+import org.apache.iceberg.FileContent;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.MetricsConfig;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.parquet.GenericParquetWriter;
+import org.apache.iceberg.encryption.EncryptedOutputFile;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.formats.FormatModel;
+import org.apache.iceberg.formats.ReadBuilder;
+import org.apache.iceberg.formats.WriteBuilder;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.DeleteSchemaUtil;
+import org.apache.iceberg.io.FileAppender;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.mapping.NameMapping;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Maps;
+import org.apache.parquet.column.ParquetProperties;
+import org.apache.parquet.schema.MessageType;
+
+public class ParquetFormatModel<D, S, F> implements FormatModel<D, S> {
+  public static final String WRITER_VERSION_KEY = "parquet.writer.version";
+
+  private final Class<? extends D> registerType;
+  private final Class<S> schemaType;
+  private final ReaderFunction<D> readerFunction;
+  private final BatchReaderFunction<D, F> batchReaderFunction;
+  private final WriterFunction<S> writerFunction;
+
+  private ParquetFormatModel(
+      Class<? extends D> registerType,
+      Class<S> schemaType,
+      ReaderFunction<D> readerFunction,
+      BatchReaderFunction<D, F> batchReaderFunction,
+      WriterFunction<S> writerFunction) {
+    this.registerType = registerType;
+    this.schemaType = schemaType;
+    this.readerFunction = readerFunction;
+    this.batchReaderFunction = batchReaderFunction;
+    this.writerFunction = writerFunction;
+  }
+
+  public ParquetFormatModel(Class<D> type) {
+    this(type, null, null, null, null);
+  }
+
+  public ParquetFormatModel(
+      Class<D> type,
+      Class<S> schemaType,
+      ReaderFunction<D> readerFunction,
+      WriterFunction<S> writerFunction) {
+    this(type, schemaType, readerFunction, null, writerFunction);
+  }
+
+  public ParquetFormatModel(
+      Class<? extends D> returnType,
+      Class<S> schemaType,
+      BatchReaderFunction<D, F> batchReaderFunction) {
+    this(returnType, schemaType, null, (BatchReaderFunction<D, F>) 
batchReaderFunction, null);
+  }
+
+  @Override
+  public FileFormat format() {
+    return FileFormat.PARQUET;
+  }
+
+  @Override
+  public Class<D> type() {
+    return (Class<D>) registerType;
+  }
+
+  @Override
+  public Class<S> schemaType() {
+    return schemaType;
+  }
+
+  @Override
+  public WriteBuilder<D, S> writeBuilder(EncryptedOutputFile outputFile) {
+    return new WriteBuilderWrapper<>(outputFile, writerFunction);
+  }
+
+  @Override
+  public ReadBuilder<D, S> readBuilder(InputFile inputFile) {
+    if (readerFunction != null) {
+      return new NonBatchReaderWrapper<>(inputFile, readerFunction);
+    } else if (batchReaderFunction != null) {
+      return new BatchReaderWrapper<>(inputFile, batchReaderFunction);
+    } else {
+      throw new IllegalStateException("Either readerFunction or 
batchReaderFunction must be set");
+    }
+  }
+
+  @FunctionalInterface
+  public interface ReaderFunction<D> {
+    ParquetValueReader<D> read(
+        Schema schema, MessageType messageType, Map<Integer, ?> 
constantValues);
+  }
+
+  @FunctionalInterface
+  public interface BatchReaderFunction<D, F> {
+    VectorizedReader<D> read(
+        Schema schema,
+        MessageType messageType,
+        Map<Integer, ?> constantValues,
+        F deleteFilter,

Review Comment:
   That PR is fixed, and rebased this one above it



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to