cshuo commented on code in PR #19079:
URL: https://github.com/apache/hudi/pull/19079#discussion_r3489925419
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieNativeLogAppendHandle.java:
##########
@@ -101,6 +101,7 @@ protected void createLogWriterForAppend(String instantTime,
Option<FileSlice> fi
getLogCreationCallback(),
config.getWriteVersion(),
config,
+ hoodieTable.getBaseFileFormat(),
Review Comment:
Should we get the format type from table config, LOG_FILE_FORMAT,
to keep it consistent with the validation in constructor of
`HoodieLsmFileGroupReader`:
https://github.com/apache/hudi/blob/1f277dd89a600ba9d0fd84578879504e1a35536b/hudi-common/src/main/java/org/apache/hudi/common/table/read/lsm/HoodieLsmFileGroupReader.java#L111-L112
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/HoodieAvroNativeCDCLogger.java:
##########
@@ -0,0 +1,260 @@
+/*
+ * 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.hudi.io;
+
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.engine.TaskContextSupplier;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodieAvroIndexedRecord;
+import org.apache.hudi.common.model.HoodieFileFormat;
+import org.apache.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieLogFile;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.schema.HoodieSchema;
+import org.apache.hudi.common.schema.HoodieSchemaCache;
+import org.apache.hudi.common.schema.HoodieSchemaUtils;
+import org.apache.hudi.common.table.HoodieTableConfig;
+import org.apache.hudi.common.table.cdc.HoodieCDCOperation;
+import org.apache.hudi.common.table.cdc.HoodieCDCSupplementalLoggingMode;
+import org.apache.hudi.common.table.cdc.HoodieCDCUtils;
+import org.apache.hudi.common.table.log.LogFileCreationCallback;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.StringUtils;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.exception.HoodieIOException;
+import org.apache.hudi.exception.HoodieUpsertException;
+import org.apache.hudi.io.storage.HoodieFileWriter;
+import org.apache.hudi.io.storage.HoodieFileWriterFactory;
+import org.apache.hudi.storage.HoodieStorage;
+import org.apache.hudi.storage.StoragePath;
+
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static
org.apache.hudi.common.table.cdc.HoodieCDCSupplementalLoggingMode.DATA_BEFORE;
+import static
org.apache.hudi.common.table.cdc.HoodieCDCSupplementalLoggingMode.DATA_BEFORE_AFTER;
+
+/**
+ * Writes CDC records as native CDC log files from Avro input records.
+ */
+public class HoodieAvroNativeCDCLogger implements
HoodieCDCLogWriter<IndexedRecord> {
Review Comment:
HoodieNativeCDCLogger.java — the two new CDC log writers duplicate nearly
all of their file-management logic (closeCDCWriter(), nextAvailableVersion(),
makeNativeCDCLogPath(), createNativeCDCLogFile(), getCDCWriteStats() are
essentially line-for-line identical). Can we make some refactor like a shared
base class or helper?
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteFunction.java:
##########
@@ -436,6 +460,7 @@ protected List<WriteStatus> writeRecords(
RowDataBucket rowDataBucket) {
writeMetrics.startFileFlush();
+ sortBucketIfNeeded(rowDataBucket);
Review Comment:
The bucket is sorted before `deduplicateRecordsIfNeeded`, but
`FlinkWriteHelper.deduplicateRecords` groups through Collectors.groupingBy(...)
and emits keyedRecords.values().stream() (FlinkWriteHelper.java:101-110). The
default HashMap order is not sorted, so PRE_COMBINE=true can feed an unsorted
incoming run into the LSM merge reader.
--
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]