somandal commented on code in PR #9982:
URL: https://github.com/apache/pinot/pull/9982#discussion_r1049088556


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/BaseIndexHandler.java:
##########
@@ -41,14 +43,19 @@
 public abstract class BaseIndexHandler implements IndexHandler {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(BaseIndexHandler.class);
 
-  protected final SegmentMetadata _segmentMetadata;
   protected final IndexLoadingConfig _indexLoadingConfig;
   protected final Set<String> _tmpForwardIndexColumns;
+  protected final SegmentDirectory _segmentDirectory;
 
-  public BaseIndexHandler(SegmentMetadata segmentMetadata, IndexLoadingConfig 
indexLoadingConfig) {
+  // The segmentMetadata may need to be updated after creating the forward 
index
+  protected SegmentMetadata _segmentMetadata;
+
+  public BaseIndexHandler(SegmentMetadata segmentMetadata, IndexLoadingConfig 
indexLoadingConfig,

Review Comment:
   thanks for the suggestion, done!



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/InvertedIndexAndDictionaryBasedForwardIndexCreator.java:
##########
@@ -218,20 +218,23 @@ public void regenerateForwardIndex()
 
     LoaderUtils.writeIndexToV3Format(_segmentWriter, _columnName, 
_forwardIndexFile, ColumnIndexType.FORWARD_INDEX);
 
-    if (!_isTemporaryForwardIndex) {
-      // Only update the metadata and cleanup other indexes if the forward 
index to be created is permanent. If the
-      // forward index is temporary, it is meant to be used only for 
construction of other indexes and will be deleted
-      // once all the IndexHandlers have completed.
-      try {
-        LOGGER.info("Created forward index from inverted index and dictionary. 
Updating metadata properties for "
-            + "segment: {}, column: {}, property list: {}", segmentName, 
_columnName, metadataProperties);
-        SegmentMetadataUtils.updateMetadataProperties(_segmentMetadata, 
metadataProperties);
-      } catch (Exception e) {
-        throw new IOException(
-            String.format("Failed to update metadata properties for segment: 
%s, column: %s", segmentName, _columnName),
-            e);
-      }
+    try {
+      // Update the metadata even for temporary forward index as other 
IndexHandlers may rely on the updated metadata
+      // to construct their indexes based on the forward index.
+      LOGGER.info("Created forward index from inverted index and dictionary. 
Updating metadata properties for "
+          + "segment: {}, column: {}, property list: {}, is temporary: {}", 
segmentName, _columnName,
+          metadataProperties, _isTemporaryForwardIndex);
+      SegmentMetadataUtils.updateMetadataProperties(_segmentMetadata, 
metadataProperties);
+    } catch (Exception e) {
+      throw new IOException(
+          String.format("Failed to update metadata properties for segment: %s, 
column: %s", segmentName, _columnName),
+          e);
+    }
 
+    if (!_isTemporaryForwardIndex) {

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