ywh19911024 commented on a change in pull request #2627:
URL: https://github.com/apache/incubator-inlong/pull/2627#discussion_r810924722
##########
File path:
inlong-sort/sort-single-tenant/src/main/java/org/apache/inlong/sort/singletenant/flink/Entrance.java
##########
@@ -121,15 +125,22 @@ private static DataFlowInfo
getDataflowInfoFromFile(String fileName) throws IOEx
SourceInfo sourceInfo,
Configuration config
) throws IOException, ClassNotFoundException {
- DeserializationSchema<Row> schema =
- DeserializationSchemaFactory.build(sourceInfo.getFields(),
sourceInfo.getDeserializationInfo());
- DeserializationFunction function = new DeserializationFunction(schema);
+ FieldInfo[] sourceFields = sourceInfo.getFields();
+ DeserializationSchema<Row> schema = DeserializationSchemaFactory.build(
+ extractNonBuiltInFieldInfo(sourceFields),
sourceInfo.getDeserializationInfo());
+ FieldMappingTransformer fieldMappingTransformer = new
FieldMappingTransformer(config, sourceFields);
+ DeserializationFunction function = new DeserializationFunction(schema,
fieldMappingTransformer);
return sourceStream.process(function)
.uid(Constants.DESERIALIZATION_SCHEMA_UID)
.name("Deserialization")
.setParallelism(config.getInteger(Constants.DESERIALIZATION_PARALLELISM));
}
+ private static FieldInfo[] extractNonBuiltInFieldInfo(FieldInfo[]
fieldInfos) {
+ return Arrays.stream(fieldInfos).filter(fieldInfo -> !(fieldInfo
instanceof BuiltInFieldInfo)).toArray(
+ FieldInfo[]::new);
+ }
+
Review comment:
这个方法放到CommonUtil这个工具类中吧
##########
File path:
inlong-sort/sort-single-tenant/src/main/java/org/apache/inlong/sort/singletenant/flink/deserialization/FieldMappingTransformer.java
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.deserialization;
+
+import org.apache.flink.types.Row;
+import org.apache.inlong.sort.configuration.Configuration;
+import org.apache.inlong.sort.configuration.Constants;
+import org.apache.inlong.sort.formats.common.FormatInfo;
+import org.apache.inlong.sort.formats.common.IntFormatInfo;
+import org.apache.inlong.sort.formats.common.LongFormatInfo;
+import org.apache.inlong.sort.formats.common.ShortFormatInfo;
+import org.apache.inlong.sort.formats.common.StringFormatInfo;
+import org.apache.inlong.sort.formats.common.TimeFormatInfo;
+import org.apache.inlong.sort.formats.common.TimestampFormatInfo;
+import org.apache.inlong.sort.protocol.BuiltInFieldInfo;
+import org.apache.inlong.sort.protocol.FieldInfo;
+
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static
org.apache.flink.shaded.guava18.com.google.common.base.Preconditions.checkNotNull;
+
+public class FieldMappingTransformer {
Review comment:
这个类可以增加些测试case
--
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]