You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/11/25 02:56:24 UTC

[GitHub] [rocketmq-externals] vongosling commented on a change in pull request #640: [ISSUE #638] add flinksql connector rocketmq

vongosling commented on a change in pull request #640:
URL: https://github.com/apache/rocketmq-externals/pull/640#discussion_r530069295



##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSink.java
##########
@@ -6,9 +6,9 @@
  * 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
- *
+ * <p>

Review comment:
       License is a standard template, Pls do not modify here.

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSink.java
##########
@@ -59,7 +60,9 @@
 
     private Properties props;
     private TopicSelector<IN> topicSelector;
-    private KeyValueSerializationSchema<IN> serializationSchema;
+    private KeyValueSerializationSchema<IN> keyValueSerializationSchema;
+    //flink sql connector serialization schema
+    private RmqSerializationSchema<IN> rmqSerializationSchema;

Review comment:
       RmqSerializationSchema is a confusing name. You Could change it to a self-explanation name such as SQLSerializationSchema class or field. 

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSink.java
##########
@@ -152,21 +166,36 @@ public void onException(Throwable throwable) {
     }
 
     private Message prepareMessage(IN input) {
-        String topic = topicSelector.getTopic(input);
-        String tag = (tag = topicSelector.getTag(input)) != null ? tag : "";
+        Validate.notNull(input, "the input is null");

Review comment:
       prepareMessage will throw runtime exception if you use validate mode in here. Is it what you expect?

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSource.java
##########
@@ -351,7 +366,15 @@ public void initializeState(FunctionInitializationContext context) throws Except
 
     @Override
     public TypeInformation<OUT> getProducedType() {
-        return schema.getProducedType();
+        if(schema != null){

Review comment:
       sql is a high priority here?

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSource.java
##########
@@ -68,7 +70,9 @@
     private transient MQPullConsumerScheduleService pullConsumerScheduleService;
     private DefaultMQPullConsumer consumer;
 
-    private KeyValueDeserializationSchema<OUT> schema;
+    private KeyValueDeserializationSchema<OUT> keyValueSchema;
+
+    private DeserializationSchema<OUT> schema;

Review comment:
       It's the same optimization todos as my suggestion.

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/RocketMQSink.java
##########
@@ -152,21 +166,36 @@ public void onException(Throwable throwable) {
     }
 
     private Message prepareMessage(IN input) {
-        String topic = topicSelector.getTopic(input);
-        String tag = (tag = topicSelector.getTag(input)) != null ? tag : "";
+        Validate.notNull(input, "the input is null");
+
+        if (keyValueSerializationSchema != null) {

Review comment:
       Is it necessary to judge not null here? since you have validated it in the open method.

##########
File path: rocketmq-flink/src/main/java/org/apache/rocketmq/flink/common/serialization/json/RmqJsonDecodingFormat.java
##########
@@ -0,0 +1,75 @@
+/**
+ * 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.rocketmq.flink.common.serialization.json;
+
+import org.apache.flink.api.common.serialization.DeserializationSchema;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.formats.json.TimestampFormat;
+import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.format.DecodingFormat;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.types.RowKind;
+
+/**
+ * @Author: gaobo07

Review comment:
       Pls, remove the author and date info. You could refer to others to do.




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

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