vernedeng commented on code in PR #7664:
URL: https://github.com/apache/inlong/pull/7664#discussion_r1155439334


##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/sort/util/FieldTypeUtils.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.manager.pojo.sort.util;
+
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flink.shaded.jackson2.org.yaml.snakeyaml.Yaml;
+import org.springframework.stereotype.Component;
+
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Util for field type convert.
+ */
+@Data
+@Component
+public class FieldTypeUtils {
+
+    private static String STREAM_FIELD_TYPE_CONFIG_YAML = 
"streamFieldMapper.yml";

Review Comment:
   There are four concepts, **_stream, sink, source, target._**
   I think it's better to unified them into two main concepts like **_Stream 
and Sink_** 



##########
inlong-manager/manager-pojo/src/main/java/org/apache/inlong/manager/pojo/sort/util/FieldTypeUtils.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.manager.pojo.sort.util;
+
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flink.shaded.jackson2.org.yaml.snakeyaml.Yaml;
+import org.springframework.stereotype.Component;
+
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Util for field type convert.
+ */
+@Data
+@Component
+public class FieldTypeUtils {
+
+    private static String STREAM_FIELD_TYPE_CONFIG_YAML = 
"streamFieldMapper.yml";
+    private static String SINK_FIELD_TYPE_CONFIG_YAML = "sinkFieldMapper.yml";
+    private static String SOUCE_TYPE = "sourceType";
+    private static String TARGET_TYPE = "targetType";
+
+    public Map<String, String> getStreamTypeConvertMap(String sourceType) 
throws Exception {
+        String path = 
Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("")).getPath()
+                + STREAM_FIELD_TYPE_CONFIG_YAML;
+        Yaml yaml = new Yaml();
+        Map<String, Map<String, String>> map = yaml.load(new 
FileInputStream(path));
+        List<Map<String, String>> list = (List<Map<String, String>>) 
map.get(sourceType);
+        Map<String, String> typeMap = new HashMap<>();
+        list.forEach(s -> {
+            typeMap.put(s.get(SOUCE_TYPE), s.get(TARGET_TYPE));
+        });
+        return typeMap;
+    }
+
+    public Map<String, String> getSinkTypeConvertMap(String sinkType) throws 
Exception {

Review Comment:
   The only difference of **_getStreamTypeConverMap_** and 
**_getSinkTypeConvertMap_** is the path of two yaml. Could you please extract 
them into one function



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