AHeise commented on a change in pull request #17501:
URL: https://github.com/apache/flink/pull/17501#discussion_r768389463



##########
File path: 
flink-formats/flink-parquet/src/main/java/org/apache/flink/formats/parquet/avro/AvroParquetReaders.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.flink.formats.parquet.avro;
+
+import org.apache.flink.api.java.typeutils.TypeExtractor;
+import org.apache.flink.formats.avro.typeutils.AvroTypeInfo;
+import org.apache.flink.formats.avro.typeutils.GenericRecordAvroTypeInfo;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.specific.SpecificRecordBase;
+
+/**
+ * Convenience builder to create {@link AvroParquetRecordFormat} instances for 
the different Avro
+ * types.
+ */
+public class AvroParquetReaders {
+
+    /**
+     * Creates a new {@link AvroParquetRecordFormat} that reads the parquet 
file into Avro {@link
+     * org.apache.avro.specific.SpecificRecord SpecificRecords}.
+     *
+     * <p>To read into Avro {@link GenericRecord GenericRecords}, use the 
{@link
+     * #forGenericRecord(Schema)} method.
+     *
+     * @see #forGenericRecord(Schema)
+     */
+    public static <T extends SpecificRecordBase> AvroParquetRecordFormat<T> 
forSpecificRecord(
+            final Class<T> typeClass) {
+        return new AvroParquetRecordFormat<>(new AvroTypeInfo<>(typeClass));
+    }
+
+    /**
+     * Creates a new {@link AvroParquetRecordFormat} that reads the parquet 
file into Avro records
+     * via reflection.
+     *
+     * <p>To read into Avro {@link GenericRecord GenericRecords}, use the 
{@link
+     * #forGenericRecord(Schema)} method.
+     *
+     * <p>To read into Avro {@link org.apache.avro.specific.SpecificRecord 
SpecificRecords}, use the
+     * {@link #forSpecificRecord(Class)} method.
+     *
+     * @see #forGenericRecord(Schema)
+     * @see #forSpecificRecord(Class)
+     */
+    public static <T> AvroParquetRecordFormat<T> forReflectRecord(final 
Class<T> typeClass) {
+        if (SpecificRecordBase.class.isAssignableFrom(typeClass)) {
+            throw new IllegalArgumentException(
+                    "Please use AvroParquetReaders.forSpecificRecord(Class<T>) 
for SpecificRecord.");

Review comment:
       Yes, I'm also torn on this one and I'd go with any of the two options.




-- 
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...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to