siddharthteotia commented on a change in pull request #7898:
URL: https://github.com/apache/pinot/pull/7898#discussion_r768291642



##########
File path: 
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/indexsegment/immutable/ImmutableSegmentLoader.java
##########
@@ -173,6 +174,34 @@ public static ImmutableSegment load(File indexDir, 
IndexLoadingConfig indexLoadi
     return segment;
   }
 
+  /**
+   * Check segment directory against the table config and schema to see if any 
preprocessing is needed,
+   * like changing segment format, adding new indices or updating default 
columns.
+   */
+  public static boolean needPreprocess(SegmentDirectory segmentDirectory, 
IndexLoadingConfig indexLoadingConfig,
+      @Nullable Schema schema)
+      throws Exception {
+    if (needConvertSegmentFormat(indexLoadingConfig, 
segmentDirectory.getSegmentMetadata())) {
+      return true;
+    }
+    SegmentPreProcessor preProcessor = new 
SegmentPreProcessor(segmentDirectory, indexLoadingConfig, schema);
+    return preProcessor.needProcess();
+  }
+
+  @VisibleForTesting
+  static boolean needConvertSegmentFormat(IndexLoadingConfig 
indexLoadingConfig,
+      SegmentMetadataImpl segmentMetadata) {
+    SegmentVersion segmentVersionToLoad = 
indexLoadingConfig.getSegmentVersion();
+    if (segmentVersionToLoad == null) {
+      return false;
+    }
+    File indexDir = segmentMetadata.getIndexDir();
+    if (indexDir != null && 
SegmentDirectoryPaths.segmentDirectoryFor(indexDir, 
segmentVersionToLoad).isDirectory()) {
+      return false;
+    }
+    return segmentVersionToLoad != segmentMetadata.getVersion();

Review comment:
       Can we make downConversion as NO-OP or throw exception like it does in 
the actual preprocess code ?




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