xiangfu0 commented on code in PR #19898:
URL: https://github.com/apache/pinot/pull/19898#discussion_r4309529573


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/SegmentPushUtils.java:
##########
@@ -462,15 +461,41 @@ private static File 
getSegmentMetadataFile(SegmentGenerationJobSpec spec, PinotF
     return generateSegmentMetadataFile(fileSystem, URI.create(tarFilePath));
   }
 
-  /// Segments stored in the deep store do not have the .tar.gz extension.
-  private static String getSegmentName(String tarFilePath) {
+  /// Resolves and validates the segment name from a supported gzip, LZ4, or 
Zstandard archive path.
+  public static String getSegmentNameFromTarFile(String tarFilePath) {
     String fileName = new File(tarFilePath).getName();
-    String segmentName = fileName.endsWith(Constants.TAR_GZ_FILE_EXT)
-        ? fileName.substring(0, fileName.length() - 
Constants.TAR_GZ_FILE_EXT.length()) : fileName;
+    Preconditions.checkArgument(Constants.isSegmentTarFile(fileName), 
"Unsupported segment archive: %s", fileName);
+    String extension = 
Constants.SEGMENT_TAR_FILE_EXTENSIONS.values().stream().filter(fileName::endsWith)
+        .findFirst().orElseThrow();
+    String segmentName = fileName.substring(0, fileName.length() - 
extension.length());
     SegmentNameUtils.validatePartialOrFullSegmentName(segmentName);
     return segmentName;
   }
 
+  /// Rejects ambiguous uploads before HTTP or segment replacement starts. 
Changing archive codecs in a reused output
+  /// directory can otherwise upload an old and a new archive of the same 
segment in an arbitrary order.
+  /// Extensionless deep-store segment paths remain supported for metadata 
push.
+  public static void validateUniqueSegmentNames(Collection<String> 
segmentPaths) {

Review Comment:
   Fixed a gap in the pattern-based remediation in 
[c51779f36b](https://github.com/apache/pinot/commit/c51779f36b12efc5a11625233b1c217e4d17cdc6).
 With both `current/segment.tar.gz` and `current/segment.tar.zst`, 
`glob:**/current/*.tar.zst` now selects the Zstandard archive before duplicate 
validation in Hadoop, Spark base, and Spark 3 metadata pushes; empty selections 
stop before upload.
   
   Validation: three runner regression tests passed on JDK 25, affected-module 
and parent precommit checks passed, and mandatory independent Pinot review 
found no issues.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to