aromanenko-dev commented on a change in pull request #16271:
URL: https://github.com/apache/beam/pull/16271#discussion_r822913878
##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/io/AvroIO.java
##########
@@ -542,18 +550,21 @@
* <p>If the output type is {@link GenericRecord} use {@link
#writeCustomTypeToGenericRecords()}
* instead.
*/
- public static <UserT, OutputT> TypedWrite<UserT, Void, OutputT>
writeCustomType() {
- return AvroIO.<UserT,
OutputT>defaultWriteBuilder().setGenericRecords(false).build();
+ public static <UserT, OutputT> TypedWrite<UserT, Void, OutputT>
writeCustomType(
+ Class<OutputT> recordClass) {
Review comment:
I guess it was a question if we can avoid breaking changes here, isn't
it?
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroReflectCoder.java
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.beam.sdk.coders;
+
+import org.apache.avro.Schema;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DatumWriter;
+import org.apache.avro.reflect.Nullable;
+import org.apache.avro.reflect.ReflectData;
+import org.apache.avro.reflect.ReflectDatumReader;
+import org.apache.avro.reflect.ReflectDatumWriter;
+import org.apache.avro.reflect.Union;
+
+/**
+ * AvroCoder specialisation for avro classes using Java reflection.
+ *
+ * <p>Only concrete classes with a no-argument constructor can be mapped to
Avro records. All
+ * inherited fields that are not static or transient are included. Fields are
not permitted to be
+ * null unless annotated by {@link Nullable} or a {@link Union} schema
containing {@code "null"}.
+ */
+public class AvroReflectCoder<T> extends AvroCoder<T> {
+
+ @SuppressWarnings("nullness") // new ReflectData(ClassLoader) is not
annotated to accept null
+ public AvroReflectCoder(Class<T> type) {
Review comment:
Why do we need public constructors?
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroGenericCoder.java
##########
@@ -18,15 +18,31 @@
package org.apache.beam.sdk.coders;
import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumReader;
+import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DatumWriter;
/** AvroCoder specialisation for GenericRecord. */
public class AvroGenericCoder extends AvroCoder<GenericRecord> {
- AvroGenericCoder(Schema schema) {
+
+ public AvroGenericCoder(Schema schema) {
Review comment:
Why do we need this be `public`?
--
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]