You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/01/24 11:33:34 UTC

[GitHub] [incubator-inlong] KevinWen007 opened a new pull request #2325: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink

KevinWen007 opened a new pull request #2325:
URL: https://github.com/apache/incubator-inlong/pull/2325


   ### Title Name: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink
   
   Fixes #2322 
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve.*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] chantccc commented on a change in pull request #2325: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] dockerzhang merged pull request #2325: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2325:
URL: https://github.com/apache/incubator-inlong/pull/2325


   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] dockerzhang merged pull request #2325: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink

Posted by GitBox <gi...@apache.org>.
dockerzhang merged pull request #2325:
URL: https://github.com/apache/incubator-inlong/pull/2325


   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] chantccc commented on a change in pull request #2325: [INLONG-2322][Feature][InLong-Sort] Support json format for kafka sink

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@inlong.apache.org

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