prashantwason commented on a change in pull request #2342:
URL: https://github.com/apache/hudi/pull/2342#discussion_r547076397
##########
File path:
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadata.java
##########
@@ -372,19 +191,6 @@ protected void closeReaders() {
logRecordScanner = null;
}
Review comment:
I think there needs to be a corresponding close() for the
timelineRecordScanner too.
Once we commit an update to the table, the unsynced instants have changed.
##########
File path:
hudi-common/src/main/java/org/apache/hudi/metadata/HoodieMetadataMergedInstantRecordScanner.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.hudi.common.model.HoodieKey;
+import org.apache.hudi.common.model.HoodieRecord;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.common.table.timeline.HoodieInstant;
+import org.apache.hudi.common.util.DefaultSizeEstimator;
+import org.apache.hudi.common.util.HoodieRecordSizeEstimator;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.collection.ExternalSpillableMap;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Provides functionality to convert timeline instants to table metadata
records and then merge by key. Specify
+ * a filter to limit keys that are merged and stored in memory.
+ */
+public class HoodieMetadataMergedInstantRecordScanner {
+
+ private static final Logger LOG =
LogManager.getLogger(HoodieMetadataMergedInstantRecordScanner.class);
+
+ HoodieTableMetaClient metaClient;
+ private List<HoodieInstant> instants;
+ private Set<String> mergeKeyFilter;
+ protected final ExternalSpillableMap<String, HoodieRecord<? extends
HoodieRecordPayload>> records;
+
+ public HoodieMetadataMergedInstantRecordScanner(HoodieTableMetaClient
metaClient, List<HoodieInstant> instants,
+ Schema readerSchema, Long
maxMemorySizeInBytes,
+ String spillableMapBasePath,
Set<String> mergeKeyFilter) throws IOException {
+ this.metaClient = metaClient;
+ this.instants = instants;
+ this.mergeKeyFilter = mergeKeyFilter != null ? mergeKeyFilter :
Collections.emptySet();
+ this.records = new ExternalSpillableMap<>(maxMemorySizeInBytes,
spillableMapBasePath, new DefaultSizeEstimator(),
+ new HoodieRecordSizeEstimator(readerSchema));
+
+ scan();
+ }
+
+ private void scan() {
+ for (HoodieInstant instant : instants) {
+ try {
+ processInstant(instant);
+ } catch (Exception e) {
+ LOG.error(String.format("Got exception when processing timeline
instant %s", instant.getTimestamp()), e);
+ throw new HoodieException(String.format("Got exception when processing
timeline instant %s", instant.getTimestamp()), e);
+ }
+ }
+ }
+
+ /**
+ * Converts an instant to metadata table records and processes each record.
+ *
+ * @param instant
+ * @throws IOException
+ */
+ private void processInstant(HoodieInstant instant) throws IOException {
Review comment:
can be merged with the above function. I dont see it being called
anywhere else.
##########
File path:
hudi-client/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
##########
@@ -266,7 +256,7 @@ private void initialize(JavaSparkContext jsc,
HoodieTableMetaClient datasetMetaC
}
private void initTableMetadata() {
- this.metadata = new HoodieBackedTableMetadata(hadoopConf.get(),
datasetWriteConfig.getBasePath(), datasetWriteConfig.getSpillableMapBasePath(),
Review comment:
The reader-write pairs in metadata are related. So this can be
simplified to be simply new HoodieBackedTableMetadata.
HoodieBackedTableMetadata cannot work with any other implementaton of
HoodieTableMetadata.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]