codope commented on code in PR #11162:
URL: https://github.com/apache/hudi/pull/11162#discussion_r1624771184


##########
hudi-common/src/main/java/org/apache/hudi/metadata/BaseTableMetadata.java:
##########
@@ -312,6 +312,33 @@ public Map<String, List<HoodieRecordGlobalLocation>> 
readRecordIndex(List<String
     return recordKeyToLocation;
   }
 
+  /**
+   * Get record-location using secondary-index and record-index
+   * <p>
+   * If the Metadata Table is not enabled, an exception is thrown to 
distinguish this from the absence of the key.
+   *
+   * @param secondaryKeys The list of secondary keys to read
+   */
+  @Override
+  public Map<String, List<HoodieRecordGlobalLocation>> 
readSecondaryIndex(List<String> secondaryKeys) {
+    
ValidationUtils.checkState(dataMetaClient.getTableConfig().isMetadataPartitionAvailable(MetadataPartitionType.RECORD_INDEX),
+        "Record index is not initialized in MDT");
+    ValidationUtils.checkState(
+        
dataMetaClient.getTableConfig().getMetadataPartitions().stream().anyMatch(partitionName
 -> 
partitionName.startsWith(MetadataPartitionType.SECONDARY_INDEX.getPartitionPath())),
+        "Secondary index is not initialized in MDT");
+    // Fetch secondary-index records
+    Map<String, List<HoodieRecord<HoodieMetadataPayload>>> secondaryKeyRecords 
= getSecondaryIndexRecords(secondaryKeys, 
MetadataPartitionType.SECONDARY_INDEX.getPartitionPath());
+    // Now collect the record-keys and fetch the RLI records

Review Comment:
   No, here it is RLI. Secondary index contains mapping from secondary key to 
primary key. So, we need to lookup RLI to get the files for those matching 
primary keys.



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