SteNicholas commented on code in PR #8503:
URL: https://github.com/apache/hudi/pull/8503#discussion_r1185994632


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/index/bucket/HoodieSparkConsistentBucketIndex.java:
##########
@@ -271,8 +327,114 @@ public Option<HoodieRecordLocation> 
getRecordLocation(HoodieKey key) {
       }
 
       LOG.error("Consistent hashing node has no file group, partition: " + 
partitionPath + ", meta: "
-          + 
partitionToIdentifier.get(partitionPath).getMetadata().getFilename() + ", 
record_key: " + key.toString());
+              + 
partitionToIdentifier.get(partitionPath).getMetadata().getFilename() + ", 
record_key: " + key.toString());
       throw new HoodieIndexException("Failed to getBucket as hashing node has 
no file group");
     }
   }
+
+  /***
+   * Create commit marker -> hoodieinstant.commit in metadata folder, 
consistent hashing metadata reader will use it to
+   * identify latest commited file which will have updated commit metadata
+   * @param table
+   * @param hoodieInstant
+   */
+  public void commitIndexMetadataIfNeeded(HoodieTable table, String 
hoodieInstant) {
+    Option<Pair<HoodieInstant, HoodieClusteringPlan>> instantPlanPair =
+            ClusteringUtils.getClusteringPlan(table.getMetaClient(), 
HoodieTimeline.getReplaceCommitRequestedInstant(hoodieInstant));
+    if (!instantPlanPair.isPresent()) {
+      return;
+    }
+    HoodieClusteringPlan plan = instantPlanPair.get().getRight();
+    List<Map<String, String>> partitionMapList = 
plan.getInputGroups().stream().map(HoodieClusteringGroup::getExtraMetadata).collect(Collectors.toList());
+    partitionMapList.stream().forEach(partitionMap -> {
+      String partition = 
partitionMap.get(SparkConsistentBucketClusteringPlanStrategy.METADATA_PARTITION_KEY);
+      Path metadataPartitionPath = 
FSUtils.getPartitionPath(table.getMetaClient().getHashingMetadataPath(), 
partition);
+      Path metadataFilePath = new Path(metadataPartitionPath, hoodieInstant + 
HASHING_METADATA_FILE_SUFFIX);
+      try {
+        if (table.getMetaClient().getFs().exists(metadataFilePath)) {
+          createCommitMarker(table, metadataFilePath, metadataPartitionPath);
+        }
+      } catch (IOException e) {
+        throw new HoodieIOException("exception while committing hashing 
metadata for path " + metadataFilePath, e);
+      }
+    });
+  }
+
+  /***
+   * Create commit marker corresponding to hashing metadata file after post 
commit clustering operation

Review Comment:
   ```suggestion
      * Creates commit marker corresponding to hashing metadata file after post 
commit clustering operation.
   ```



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to