yuanbenson commented on code in PR #9295: URL: https://github.com/apache/pinot/pull/9295#discussion_r959049111
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/SegmentPushUtils.java: ########## @@ -371,4 +372,36 @@ private static File generateSegmentMetadataFile(PinotFS fileSystem, URI tarFileU FileUtils.deleteQuietly(segmentMetadataDir); } } + + public static List<String> getSegmentNames(BatchConfigProperties.SegmentPushType pushMode, + Map<String, String> segmentsUriToTarPathMap) { + List<String> segmentNames = new ArrayList<>(); + if (pushMode.equals(BatchConfigProperties.SegmentPushType.TAR) || pushMode.equals( + BatchConfigProperties.SegmentPushType.METADATA)) { + for (String tarFilePath : segmentsUriToTarPathMap.values()) { + File tarFile = new File(tarFilePath); + String fileName = tarFile.getName(); + Preconditions.checkArgument(fileName.endsWith(Constants.TAR_GZ_FILE_EXT)); + String segmentName = getSegmentNameFromPath(fileName); + segmentNames.add(segmentName); + } + } + if (pushMode.equals(BatchConfigProperties.SegmentPushType.URI)) { + for (String segmentUri : segmentsUriToTarPathMap.keySet()) { + Preconditions.checkArgument(segmentUri.endsWith(Constants.TAR_GZ_FILE_EXT)); + String segmentName = getSegmentNameFromPath(segmentUri); + segmentNames.add(segmentName); + } + } + return segmentNames; + } + + /** + * Obtain segment name given filePath by reading from after the last slash (if present) up to and before the tar + * extension. + */ + public static String getSegmentNameFromPath(String filePath) { + int startIndex = filePath.contains("/") ? filePath.lastIndexOf("/") + 1 : 0; Review Comment: Thanks for the reminder! -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org