chenboat commented on code in PR #18467:
URL: https://github.com/apache/pinot/pull/18467#discussion_r3267933734


##########
pinot-server/src/main/java/org/apache/pinot/server/predownload/PredownloadSegmentInfo.java:
##########
@@ -172,9 +176,27 @@ public boolean hasSameCRC() {
     }
   }
 
-  public void updateSegmentInfoFromLocal(@Nullable SegmentDirectory 
segmentDirectory) {
-    SegmentMetadataImpl segmentMetadata = (segmentDirectory == null) ? null : 
segmentDirectory.getSegmentMetadata();
-    _localCrc = (segmentMetadata == null) ? null : segmentMetadata.getCrc();
-    _localSizeBytes = (segmentDirectory == null) ? 0 : 
segmentDirectory.getDiskSizeBytes();
+  /**
+   * Populates local CRC and size from the segment directory on disk, avoiding 
mmap of index files.
+   * Reads CRC from {@code creation.meta} (8 bytes) and computes size via 
directory traversal.
+   * Sets {@code _localCrc} to null and {@code _localSizeBytes} to 0 if the 
segment or its
+   * creation.meta does not exist.
+   */
+  public void updateSegmentInfoFromLocal(File segDir) {
+    if (!segDir.isDirectory()) {
+      LOGGER.warn("Segment path is not a directory: {}", segDir);
+      return;
+    }
+    File creationMeta = SegmentDirectoryPaths.findCreationMetaFile(segDir);
+    if (creationMeta == null || !creationMeta.exists()) {
+      return;
+    }
+    try (DataInputStream ds = new DataInputStream(new 
FileInputStream(creationMeta))) {

Review Comment:
   To confirm, the first 8 bytes of creationMeta is CRC? Add a comment above 
this line could be help.



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