cshuo commented on code in PR #13411: URL: https://github.com/apache/hudi/pull/13411#discussion_r2148900762
########## hudi-client/hudi-client-common/src/main/java/org/apache/hudi/io/FileGroupReaderBasedAppendHandle.java: ########## @@ -0,0 +1,120 @@ +/* + * 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.client.WriteStatus; +import org.apache.hudi.common.config.HoodieMemoryConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.engine.HoodieReaderContext; +import org.apache.hudi.common.engine.TaskContextSupplier; +import org.apache.hudi.common.model.CompactionOperation; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.table.read.HoodieFileGroupReader; +import org.apache.hudi.common.table.read.HoodieReadStats; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.config.HoodieWriteConfig; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.exception.HoodieUpsertException; +import org.apache.hudi.internal.schema.InternalSchema; +import org.apache.hudi.internal.schema.utils.SerDeHelper; +import org.apache.hudi.table.HoodieTable; +import org.apache.hudi.table.action.compact.strategy.CompactionStrategy; + +import javax.annotation.concurrent.NotThreadSafe; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import static org.apache.hudi.common.config.HoodieReaderConfig.MERGE_USE_RECORD_POSITIONS; + +/** + * A base append handle implementation based on the {@link HoodieFileGroupReader}. + * <p> + * This append-handle is used for log-compaction, which passes a file slice from the + * compaction operation of a single file group to a file group reader, get an iterator of + * the records, and writes the records to a new log file. + */ +@NotThreadSafe +public class FileGroupReaderBasedAppendHandle<T, I, K, O> extends HoodieAppendHandle<T, I, K, O> { + private final HoodieReaderContext<T> readerContext; + private final FileSlice fileSlice; + private final CompactionOperation operation; + private HoodieReadStats readStats; + + public FileGroupReaderBasedAppendHandle(HoodieWriteConfig config, String instantTime, HoodieTable<T, I, K, O> hoodieTable, + FileSlice fileSlice, CompactionOperation operation, TaskContextSupplier taskContextSupplier, + HoodieReaderContext<T> readerContext) { + super(config, instantTime, hoodieTable, operation.getPartitionPath(), operation.getFileId(), taskContextSupplier); + this.operation = operation; + this.readerContext = readerContext; + this.fileSlice = fileSlice; + } + + @Override + public void doAppend() { + boolean usePosition = config.getBooleanOrDefault(MERGE_USE_RECORD_POSITIONS); Review Comment: Seems `PositionBasedFileGroupRecordBuffer` has a fallback checking if there is no record positions in data block, so checking for engine type is not needed actually. -- 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]
