prashantwason commented on code in PR #8493: URL: https://github.com/apache/hudi/pull/8493#discussion_r1172175882
########## hudi-common/src/main/java/org/apache/hudi/metadata/HoodieTableMetadataUtil.java: ########## @@ -1004,6 +1004,44 @@ public static int mapRecordKeyToFileGroupIndex(String recordKey, int numFileGrou return Math.abs(Math.abs(h) % numFileGroups); } + /** + * Return the complete fileID for a file group within a MDT partition. + * + * MDT fileGroups have the format <fileIDPrefix>-<index>. The fileIDPrefix is hardcoded for each MDT partition and index is an integer. + * + * @param partitionType The type of the MDT partition + * @param index Index of the file group within the partition + * @return The fileID + */ + public static String getFileIDForFileGroup(MetadataPartitionType metadataPartition, int index) { + return String.format("%s%04d", metadataPartition.getFileIdPrefix(), index); + } + + /** + * Extract the index from the fileID of a file group in the MDT partition. See {@code getFileIDForFileGroup} for the format of the fileID. + * + * @param fileId fileID of a file group. + * @return The index of file group + */ + public static int getFileGroupIndexFromFileId(String fileId) { + // 0.10 version MDT code added -0 (0th fileIndex) to the fileID + int endIndex = fileId.endsWith("-0") ? fileId.length() - 2 : fileId.length(); + int fromIndex = fileId.lastIndexOf("-", endIndex); Review Comment: Done -- 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