You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/08/07 10:00:24 UTC

[GitHub] dawidwys commented on a change in pull request #6259: [FLINK-9679] Implement AvroSerializationSchema

dawidwys commented on a change in pull request #6259: [FLINK-9679] Implement AvroSerializationSchema
URL: https://github.com/apache/flink/pull/6259#discussion_r208167325
 
 

 ##########
 File path: flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/RegistryAvroSerializationSchema.java
 ##########
 @@ -0,0 +1,76 @@
+/*
+ * 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.avro;
+
+import org.apache.avro.io.Encoder;
+import org.apache.avro.specific.SpecificRecord;
+
+import java.io.IOException;
+
+/**
+ * Serialization schema that serializes from Avro binary format.
+ *
+ * @param <T> type of record it produces
+ */
+public class RegistryAvroSerializationSchema<T> extends AvroSerializationSchema<T> {
+
+	private static final long serialVersionUID = -6766681879020862312L;
+
+	/** Provider for schema coder. Used for initializing in each task. */
+	private final SchemaCoder.SchemaCoderProvider schemaCoderProvider;
+
+	/** Class to serialize to. */
+	private final Class<T> recordClazz;
+
+	/**
+	 * Creates Avro Serialization schema.
+	 *
+	 * @param recordClazz         class to which serialize which is
+	 *                            {@link SpecificRecord}.
+	 * @param schemaCoderProvider schema provider that allows instantiation of {@link SchemaCoder} that will be used for
+	 *                            schema writing
+	 */
+	public RegistryAvroSerializationSchema(Class<T> recordClazz, SchemaCoder.SchemaCoderProvider schemaCoderProvider) {
 
 Review comment:
   Make it private and add factory methods: `forSpecific` and `forGeneric`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services