yihua commented on code in PR #18348:
URL: https://github.com/apache/hudi/pull/18348#discussion_r3048367063


##########
hudi-common/src/main/java/org/apache/hudi/metadata/model/FileSliceAndPartition.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.model;
+
+import org.apache.hudi.common.model.FileSlice;
+
+import lombok.AllArgsConstructor;
+import lombok.ToString;
+import lombok.Getter;
+import lombok.experimental.Accessors;
+
+/**
+ * Holder for a {@link FileSlice} and its partition path.
+ */
+@AllArgsConstructor
+@Getter
+@ToString
+@Accessors(fluent = true)
+public class FileSliceAndPartition {
+  private final FileSlice fileSlice;
+  private final String partitionPath;
+
+  public static FileSliceAndPartition of(String partitionPath, FileSlice 
fileSlice) {

Review Comment:
   🤖 nit: the factory method parameter order (partitionPath, fileSlice) is 
opposite to the field declaration and auto-generated constructor order 
(fileSlice, partitionPath). Consider reordering the fields to match the more 
natural API order, or vice versa, for consistency.



##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -286,26 +265,26 @@ public HoodieBackedTableMetadata getTableMetadata() {
   protected boolean initializeIfNeeded(HoodieTableMetaClient dataMetaClient,
                                        Option<String> 
inflightInstantTimestamp) throws IOException {
     HoodieTimer timer = HoodieTimer.start();
-    List<MetadataPartitionType> metadataPartitionsToInit = new 
ArrayList<>(MetadataPartitionType.getValidValues().length);
+    Map<MetadataPartitionType, Indexer> indexerMapForPartitionsToInit = new 
HashMap<>();
 
     try {
       boolean exists = metadataTableExists(dataMetaClient);
       if (!exists) {
         // FILES partition is always required
-        metadataPartitionsToInit.add(FILES);
+        indexerMapForPartitionsToInit.put(FILES, enabledIndexerMap.get(FILES));
       }
 
       // check if any of the enabled partition types needs to be initialized
       // NOTE: It needs to be guarded by async index config because if that is 
enabled then initialization happens through the index scheduler.
       if (!dataWriteConfig.isMetadataAsyncIndex()) {
         Set<String> completedPartitions = 
dataMetaClient.getTableConfig().getMetadataPartitions();
         LOG.info("Async metadata indexing disabled and following partitions 
already initialized: {}", completedPartitions);
-        this.enabledPartitionTypes.stream()
-            .filter(p -> !completedPartitions.contains(p.getPartitionPath()) 
&& !FILES.equals(p))
-            .forEach(metadataPartitionsToInit::add);
+        this.enabledIndexerMap.entrySet().stream()
+            .filter(p -> 
!completedPartitions.contains(p.getKey().getPartitionPath()) && FILES != 
p.getKey())
+            .forEach(e -> indexerMapForPartitionsToInit.put(e.getKey(), 
e.getValue()));
       }

Review Comment:
   🤖 nit: could you use consistent variable names in the stream pipeline? The 
filter lambda uses `p` while forEach uses `e`, both for the same Map.Entry 
type—consider using `entry` or `e` consistently throughout.



-- 
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]

Reply via email to