danny0405 commented on code in PR #9819: URL: https://github.com/apache/hudi/pull/9819#discussion_r1465827024
########## hudi-common/src/main/java/org/apache/hudi/common/table/read/HoodieBaseFileGroupRecordBuffer.java: ########## @@ -0,0 +1,279 @@ +/* + * 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.common.table.read; + +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.engine.HoodieReaderContext; +import org.apache.hudi.common.model.DeleteRecord; +import org.apache.hudi.common.model.HoodieRecord; +import org.apache.hudi.common.model.HoodieRecordMerger; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.log.KeySpec; +import org.apache.hudi.common.table.log.block.HoodieDataBlock; +import org.apache.hudi.common.table.log.block.HoodieLogBlock; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.ReflectionUtils; +import org.apache.hudi.common.util.collection.ClosableIterator; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieCorruptedDataException; +import org.apache.hudi.exception.HoodieKeyException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.avro.Schema; +import org.roaringbitmap.longlong.Roaring64NavigableMap; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public abstract class HoodieBaseFileGroupRecordBuffer<T> implements HoodieFileGroupRecordBuffer<T> { + protected final HoodieReaderContext<T> readerContext; + protected final Schema readerSchema; + protected final Schema baseFileSchema; + protected final Option<String> partitionNameOverrideOpt; + protected final Option<String[]> partitionPathFieldOpt; + protected final HoodieRecordMerger recordMerger; + protected final TypedProperties payloadProps; + protected final HoodieTableMetaClient hoodieTableMetaClient; + protected final Map<Object, Pair<Option<T>, Map<String, Object>>> records; + protected ClosableIterator<T> baseFileIterator; + protected Iterator<Pair<Option<T>, Map<String, Object>>> logRecordIterator; + protected T nextRecord; + + public HoodieBaseFileGroupRecordBuffer(HoodieReaderContext<T> readerContext, + Schema readerSchema, + Schema baseFileSchema, + Option<String> partitionNameOverrideOpt, + Option<String[]> partitionPathFieldOpt, + HoodieRecordMerger recordMerger, + TypedProperties payloadProps, + HoodieTableMetaClient hoodieTableMetaClient) { + this.readerContext = readerContext; + this.readerSchema = readerSchema; + this.baseFileSchema = baseFileSchema; + this.partitionNameOverrideOpt = partitionNameOverrideOpt; + this.partitionPathFieldOpt = partitionPathFieldOpt; + this.recordMerger = recordMerger; + this.payloadProps = payloadProps; + this.hoodieTableMetaClient = hoodieTableMetaClient; + this.records = new HashMap<>(); Review Comment: The sequence of the log records got lost by using the `HashMap#values`, we should fix it. And in general, should we cache all the log records in memory, I don't think it is reasonable, when the base file is empty, it is feasible we just keep an iterator of the log files. -- 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]
