J-HowHuang commented on code in PR #19861:
URL: https://github.com/apache/pinot/pull/19861#discussion_r4280663918


##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java:
##########
@@ -712,41 +712,55 @@ public static void deleteSegmentFilesFromDisk(String 
tableDataDir, String segmen
   }
 
   @Override
-  public void reloadSegment(String segmentName, boolean forceDownload, String 
reloadJobId)
+  public void reloadSegment(String segmentName, boolean forceDownload, boolean 
onlyIfNeeded, String reloadJobId)
       throws Exception {
     Preconditions.checkState(!_shutDown,
         "Table data manager is already shut down, cannot reload segment: %s in 
table: %s", segmentName,
         _tableNameWithType);
-    _logger.info("Reloading segment: {} with forceDownload: {}", segmentName, 
forceDownload);
+    _logger.info("Reloading segment: {} with forceDownload: {}, onlyIfNeeded: 
{}", segmentName, forceDownload,
+        onlyIfNeeded);
     SegmentDataManager segmentDataManager = 
_segmentDataManagerMap.get(segmentName);
     if (segmentDataManager != null) {
       IndexLoadingConfig indexLoadingConfig = fetchIndexLoadingConfig();
+      if (onlyIfNeeded && !forceDownload && 
selectSegmentsNeedingReload(List.of(segmentDataManager),

Review Comment:
   done



##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java:
##########
@@ -758,7 +772,12 @@ public void reloadSegments(List<String> segmentNames, 
boolean forceDownload, Str
       }
     }
     if (!segmentDataManagers.isEmpty()) {
-      reloadSegments(segmentDataManagers, fetchIndexLoadingConfig(), 
forceDownload, reloadJobId);
+      IndexLoadingConfig indexLoadingConfig = fetchIndexLoadingConfig();
+      List<SegmentDataManager> segmentsToReload = onlyIfNeeded && 
!forceDownload
+          ? selectSegmentsNeedingReload(segmentDataManagers, 
indexLoadingConfig, reloadJobId) : segmentDataManagers;
+      if (!segmentsToReload.isEmpty()) {
+        reloadSegments(segmentsToReload, indexLoadingConfig, forceDownload, 
reloadJobId);
+      }
     }
     if (missingSegments.isEmpty()) {
       _logger.info("Reloaded segments: {} with forceDownload: {}", 
segmentNames, forceDownload);

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