flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] dawidwys commented on a change in pull request #6259: [FLINK-9679] Implement AvroSerializationSchema
Date Tue, 07 Aug 2018 10:00:24 GMT
dawidwys commented on a change in pull request #6259: [FLINK-9679] Implement AvroSerializationSchema
URL: https://github.com/apache/flink/pull/6259#discussion_r208166760
 
 

 ##########
 File path: flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroSerializationSchema.java
 ##########
 @@ -0,0 +1,134 @@
+/*
+ * 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.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericDatumWriter;
+import org.apache.avro.io.BinaryEncoder;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.avro.specific.SpecificData;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.avro.specific.SpecificRecord;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * Serialization schema that serializes from Avro binary format.
+ *
+ * @param <T> type of record it produces
+ */
+public class AvroSerializationSchema<T> implements SerializationSchema<T> {
+
+	/**
+	 * Creates {@link AvroSerializationSchema} that produces {@link SpecificRecord} using provided
schema.
+	 *
+	 * @param tClass class of record to be produced
+	 * @return topic record in form of {@link SpecificRecord}
+	 */
+	public static <T extends SpecificRecord> AvroSerializationSchema<T> forSpecific(Class<T>
tClass) {
 
 Review comment:
   Missing factory method `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

Mime
View raw message