baomingyu commented on code in PR #9780:
URL: https://github.com/apache/inlong/pull/9780#discussion_r1515412376


##########
inlong-sort/sort-formats/format-rowdata/format-inlongmsg-rowdata-tlogkv/src/main/java/org/apache/inlong/sort/formats/inlongmsgtlogkv/InLongMsgTlogKvFormatDeserializer.java:
##########
@@ -0,0 +1,334 @@
+/*
+ * 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.formats.inlongmsgtlogkv;
+
+import org.apache.inlong.sort.formats.base.FieldToRowDataConverters;
+import 
org.apache.inlong.sort.formats.base.FieldToRowDataConverters.FieldToRowDataConverter;
+import org.apache.inlong.sort.formats.base.TableFormatUtils;
+import org.apache.inlong.sort.formats.base.TextFormatBuilder;
+import org.apache.inlong.sort.formats.common.RowFormatInfo;
+import 
org.apache.inlong.sort.formats.inlongmsg.AbstractInLongMsgFormatDeserializer;
+import org.apache.inlong.sort.formats.inlongmsg.FailureHandler;
+import org.apache.inlong.sort.formats.inlongmsg.InLongMsgBody;
+import org.apache.inlong.sort.formats.inlongmsg.InLongMsgHead;
+import org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.descriptors.DescriptorProperties;
+import org.apache.flink.table.types.logical.RowType;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.DEFAULT_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.DEFAULT_ENTRY_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.DEFAULT_KV_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_ATTRIBUTE_FIELD_NAME;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_ENTRY_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_KV_DELIMITER;
+import static 
org.apache.inlong.sort.formats.base.TableFormatConstants.FORMAT_TIME_FIELD_NAME;
+import static 
org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils.DEFAULT_ATTRIBUTES_FIELD_NAME;
+import static 
org.apache.inlong.sort.formats.inlongmsg.InLongMsgUtils.DEFAULT_TIME_FIELD_NAME;
+import static 
org.apache.inlong.sort.formats.inlongmsgtlogkv.InLongMsgTlogKvUtils.DEFAULT_INLONGMSG_TLOGKV_CHARSET;
+
+/**
+ * The deserializer for the records in InLongMsgTlogKV format.
+ */
+public final class InLongMsgTlogKvFormatDeserializer extends 
AbstractInLongMsgFormatDeserializer {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Format information describing the result type.
+     */
+    @Nonnull
+    private final RowFormatInfo rowFormatInfo;
+
+    /**
+     * The name of the time field.
+     */
+    @Nullable
+    private final String timeFieldName;
+
+    /**
+     * The name of the attributes field.
+     */
+    @Nullable
+    private final String attributesFieldName;
+
+    /**
+     * The charset of the text.
+     */
+    @Nonnull
+    private final String charset;
+
+    /**
+     * The delimiter between fields.
+     */
+    @Nonnull
+    private final Character delimiter;
+
+    /**
+     * The delimiter between entries.
+     */
+    @Nonnull
+    private final Character entryDelimiter;
+
+    /**
+     * The delimiter between key and value.
+     */
+    @Nonnull
+    private final Character kvDelimiter;
+
+    /**
+     * Escape character. Null if escaping is disabled.
+     */
+    @Nullable
+    private final Character escapeChar;
+
+    /**
+     * Quote character. Null if quoting is disabled.
+     */
+    @Nullable
+    private final Character quoteChar;
+
+    /**
+     * The literal represented null values, default "".
+     */
+    @Nullable
+    private final String nullLiteral;
+
+    private final FieldToRowDataConverter[] converters;
+
+    public InLongMsgTlogKvFormatDeserializer(
+            @Nonnull RowFormatInfo rowFormatInfo,
+            @Nullable String timeFieldName,
+            @Nullable String attributesFieldName,
+            @Nonnull String charset,
+            @Nonnull Character delimiter,
+            @Nonnull Character entryDelimiter,
+            @Nonnull Character kvDelimiter,
+            @Nullable Character escapeChar,
+            @Nullable Character quoteChar,
+            @Nullable String nullLiteral,
+            @Nonnull Boolean ignoreErrors) {
+        this(
+                rowFormatInfo,
+                timeFieldName,
+                attributesFieldName,
+                charset,
+                delimiter,
+                entryDelimiter,
+                kvDelimiter,
+                escapeChar,
+                quoteChar,
+                nullLiteral,
+                InLongMsgUtils.getDefaultExceptionHandler(ignoreErrors));
+    }
+
+    public InLongMsgTlogKvFormatDeserializer(
+            @Nonnull RowFormatInfo rowFormatInfo,
+            @Nullable String timeFieldName,
+            @Nullable String attributesFieldName,
+            @Nonnull String charset,
+            @Nonnull Character delimiter,
+            @Nonnull Character entryDelimiter,
+            @Nonnull Character kvDelimiter,
+            @Nullable Character escapeChar,
+            @Nullable Character quoteChar,
+            @Nullable String nullLiteral,
+            @Nonnull FailureHandler failureHandler) {
+        super(failureHandler);
+
+        this.rowFormatInfo = rowFormatInfo;
+        this.timeFieldName = timeFieldName;
+        this.attributesFieldName = attributesFieldName;
+        this.charset = charset;
+        this.delimiter = delimiter;
+        this.entryDelimiter = entryDelimiter;
+        this.kvDelimiter = kvDelimiter;
+        this.escapeChar = escapeChar;
+        this.quoteChar = quoteChar;
+        this.nullLiteral = nullLiteral;
+
+        this.converters = Arrays.stream(rowFormatInfo.getFieldFormatInfos())
+                .map(formatInfo -> FieldToRowDataConverters.createConverter(
+                        TableFormatUtils.deriveLogicalType(formatInfo)))
+                
.toArray(FieldToRowDataConverters.FieldToRowDataConverter[]::new);
+    }
+
+    @Override
+    public TypeInformation<RowData> getProducedType() {
+        return 
InLongMsgUtils.decorateRowDataTypeWithNeededHeadFields(timeFieldName,
+                attributesFieldName, (RowType) 
TableFormatUtils.deriveLogicalType(rowFormatInfo));
+    }
+
+    @Override
+    protected InLongMsgHead parseHead(String attr) throws Exception {
+        return InLongMsgTlogKvUtils.parseHead(attr);
+    }
+
+    @Override
+    protected List<InLongMsgBody> parseBodyList(byte[] bytes) throws Exception 
{
+        return Collections.singletonList(
+                InLongMsgTlogKvUtils.parseBody(
+                        bytes,
+                        charset,
+                        delimiter,
+                        entryDelimiter,
+                        kvDelimiter,
+                        escapeChar,
+                        quoteChar));
+    }
+
+    @Override
+    protected List<RowData> convertRowDataList(InLongMsgHead head, 
InLongMsgBody body) throws Exception {
+        GenericRowData rowD =

Review Comment:
   done change to genericRowData



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