Jackie-Jiang commented on code in PR #11711:
URL: https://github.com/apache/pinot/pull/11711#discussion_r1344488600


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/SegmentIndexCreationDriverImpl.java:
##########
@@ -336,6 +349,39 @@ private void handlePostCreation()
     LOGGER.info("Driver, indexing time : {}", _totalIndexTime);
   }
 
+  private void updatePostSegmentCreationIndexes(File indexDir) throws 
Exception {
+    Set<IndexType> postSegCreationIndexes = 
IndexService.getInstance().getAllIndexes().stream()
+        .filter(indexType -> indexType.getIndexBuildLifecycle() == 
IndexType.BuildLifecycle.POST_SEGMENT_CREATION)
+        .collect(Collectors.toSet());
+
+    if (postSegCreationIndexes.size() > 0) {
+      // Build other indexes
+      Map<String, Object> props = new HashMap<>();
+      props.put(IndexLoadingConfig.READ_MODE_KEY, ReadMode.mmap);
+      PinotConfiguration segmentDirectoryConfigs = new 
PinotConfiguration(props);
+
+      SegmentDirectoryLoaderContext segmentLoaderContext =
+          new 
SegmentDirectoryLoaderContext.Builder().setTableConfig(_config.getTableConfig())
+              .setSchema(_config.getSchema()).setSegmentName(_segmentName)
+              .setSegmentDirectoryConfigs(segmentDirectoryConfigs).build();
+
+      IndexLoadingConfig indexLoadingConfig =
+          new IndexLoadingConfig(null, _config.getTableConfig(), 
_config.getSchema());
+
+      try (SegmentDirectory segmentDirectory = 
SegmentDirectoryLoaderRegistry.getDefaultSegmentDirectoryLoader()
+          .load(indexDir.toURI(), segmentLoaderContext);
+          SegmentDirectory.Writer segmentWriter = 
segmentDirectory.createWriter()) {
+        for (IndexType indexType : postSegCreationIndexes) {
+          IndexHandler handler =
+              indexType.createIndexHandler(segmentDirectory, 
indexLoadingConfig.getFieldIndexConfigByColName(),
+                  _config.getSchema(), _config.getTableConfig());
+          handler.updateIndices(segmentWriter);
+        }
+      }
+    }
+  }
+

Review Comment:
   (nit) extra empty line (should probably add a check-style rule for this)



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

Reply via email to