alexeykudinkin commented on code in PR #6782: URL: https://github.com/apache/hudi/pull/6782#discussion_r1073025051
########## hudi-common/src/main/java/org/apache/hudi/metadata/HoodieMetadataLogRecordReader.java: ########## @@ -0,0 +1,234 @@ +/* + * 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.metadata; + +import org.apache.avro.Schema; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hudi.common.model.HoodieAvroRecordMerger; +import org.apache.hudi.common.model.HoodieRecord; +import org.apache.hudi.common.table.log.HoodieMergedLogRecordScanner; +import org.apache.hudi.common.table.log.InstantRange; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.ExternalSpillableMap; + +import javax.annotation.concurrent.ThreadSafe; +import java.io.Closeable; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * Metadata log-block records reading implementation, internally relying on + * {@link HoodieMergedLogRecordScanner} to merge corresponding Metadata Table's delta log-blocks + * sequence + */ +@ThreadSafe +public class HoodieMetadataLogRecordReader implements Closeable { + + private final HoodieMergedLogRecordScanner logRecordScanner; + + private HoodieMetadataLogRecordReader(HoodieMergedLogRecordScanner logRecordScanner) { + this.logRecordScanner = logRecordScanner; + } + + /** + * Returns the builder for {@code HoodieMetadataMergedLogRecordScanner}. + */ + public static HoodieMetadataLogRecordReader.Builder newBuilder() { + return new HoodieMetadataLogRecordReader.Builder(); + } + + @SuppressWarnings("unchecked") + public List<HoodieRecord<HoodieMetadataPayload>> getRecords() { + // NOTE: Locking is necessary since we're accessing [[HoodieMetadataLogRecordReader]] + // materialized state, to make sure there's no concurrent access + synchronized (this) { Review Comment: Discussed offline: these locks have different purpose and are necessary for their own purposes. If we want to revisit these we'll take it up separately -- 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]
