chantccc commented on a change in pull request #2325:
URL: https://github.com/apache/incubator-inlong/pull/2325#discussion_r791297571



##########
File path: 
inlong-sort/sort-single-tenant/src/main/java/org/apache/inlong/sort/singletenant/flink/serialization/RowSerializationSchemaBuilder.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.inlong.sort.singletenant.flink.serialization;
+
+import org.apache.flink.api.common.serialization.SerializationSchema;
+import org.apache.flink.api.java.typeutils.RowTypeInfo;
+import org.apache.flink.formats.json.JsonRowSerializationSchema;
+import org.apache.flink.types.Row;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.serialization.JsonSerializationInfo;
+import org.apache.inlong.sort.protocol.serialization.SerializationInfo;
+import org.apache.inlong.sort.protocol.sink.SinkInfo;
+
+import java.nio.charset.StandardCharsets;
+
+import static 
org.apache.inlong.sort.singletenant.flink.utils.CommonUtils.convertFieldInfosToRowTypeInfo;
+
+public class RowSerializationSchemaBuilder {

Review comment:
       RowSerializationSchemaFactory maybe better?

##########
File path: 
inlong-sort/sort-single-tenant/src/main/java/org/apache/inlong/sort/singletenant/flink/utils/CommonUtils.java
##########
@@ -38,4 +59,70 @@ public static TableSchema getTableSchema(SinkInfo sinkInfo) {
 
         return builder.build();
     }
+
+    public static org.apache.flink.api.java.typeutils.RowTypeInfo 
convertFieldInfosToRowTypeInfo(
+            FieldInfo[] fieldInfos
+    ) {
+        int length = fieldInfos.length;
+        TypeInformation<?>[] typeInformationArray = new 
TypeInformation[length];
+        String[] fieldNames = new String[length];
+        for (int i = 0; i < length; i++) {
+            FieldInfo fieldInfo = fieldInfos[i];
+            fieldNames[i] = fieldInfo.getName();
+
+            TypeInfo typeInfo = fieldInfo.getFormatInfo().getTypeInfo();
+            typeInformationArray[i] = getTypeInformationFromTypeInfo(typeInfo);
+        }
+
+        return new 
org.apache.flink.api.java.typeutils.RowTypeInfo(typeInformationArray, 
fieldNames);
+    }
+
+    @VisibleForTesting
+    static TypeInformation<?> getTypeInformationFromTypeInfo(TypeInfo 
typeInfo) {

Review comment:
       The function is same with 
org.apache.inlong.sort.formats.base.TableFormatUtils.getType(TypeInfo typeInfo)




-- 
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]


Reply via email to