Copilot commented on code in PR #18408:
URL: https://github.com/apache/pinot/pull/18408#discussion_r3179076928


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexType.java:
##########
@@ -204,11 +203,12 @@ public InvertedIndexReader 
createIndexReader(SegmentDirectory.Reader segmentRead
     public InvertedIndexReader createSkippingForward(SegmentDirectory.Reader 
segmentReader, ColumnMetadata metadata)
         throws IOException {
       PinotDataBuffer dataBuffer = 
segmentReader.getIndexFor(metadata.getColumnName(), StandardIndexes.inverted());
-      if (metadata.hasDictionary()) {
-        return new BitmapInvertedIndexReader(dataBuffer, 
metadata.getCardinality());
-      } else {
-        return new RawValueBitmapInvertedIndexReader(dataBuffer, 
metadata.getDataType());
-      }
+      Preconditions.checkState(metadata.hasDictionary(),
+          "Inverted index for column %s exists but no dictionary is present; 
the segment may contain a legacy "
+              + "embedded-dictionary inverted index. Re-run segment 
preprocessing with a non-null table config "
+              + "and schema to migrate the index to the standard dict-id-based 
format.",
+          metadata.getColumnName());

Review Comment:
   This no longer degrades gracefully when an inverted-index file exists on a 
column without a dictionary. `PhysicalColumnIndexContainer` only suppresses 
`IndexReaderConstraintException`, so this `checkState` now aborts segment 
loading instead of returning `null` and letting the caller fall back to a scan. 
That breaks the legacy-segment case called out in the PR description when 
preprocessing is skipped or hasn't run yet.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/invertedindex/RangeIndexHandler.java:
##########
@@ -167,17 +169,25 @@ private void 
handleDictionaryBasedColumn(SegmentDirectory.Writer segmentWriter,
         _fieldIndexConfigs.get(columnMetadata.getColumnName()), 
columnMetadata);
         ForwardIndexReaderContext readerContext = 
forwardIndexReader.createContext();
         CombinedInvertedIndexCreator rangeIndexCreator = 
newRangeIndexCreator(columnMetadata)) {
-      if (columnMetadata.isSingleValue()) {
-        // Single-value column
-        for (int i = 0; i < numDocs; i++) {
-          rangeIndexCreator.add(forwardIndexReader.getDictId(i, 
readerContext));
+      if (forwardIndexReader.isDictionaryEncoded()) {
+        if (columnMetadata.isSingleValue()) {
+          // Single-value column
+          for (int i = 0; i < numDocs; i++) {
+            rangeIndexCreator.add(forwardIndexReader.getDictId(i, 
readerContext));
+          }
+        } else {
+          // Multi-value column
+          int[] dictIds = new int[columnMetadata.getMaxNumberOfMultiValues()];
+          for (int i = 0; i < numDocs; i++) {
+            int length = forwardIndexReader.getDictIdMV(i, dictIds, 
readerContext);
+            rangeIndexCreator.add(dictIds, length);
+          }
         }
       } else {
-        // Multi-value column
-        int[] dictIds = new int[columnMetadata.getMaxNumberOfMultiValues()];
-        for (int i = 0; i < numDocs; i++) {
-          int length = forwardIndexReader.getDictIdMV(i, dictIds, 
readerContext);
-          rangeIndexCreator.add(dictIds, length);
+        try (Dictionary dictionary = DictionaryIndexType.read(segmentWriter, 
columnMetadata)) {
+          
DictionaryBasedIndexBuilder.addRawValuesViaDictionary(rangeIndexCreator, 
forwardIndexReader, readerContext,
+              dictionary,
+              columnMetadata, numDocs);

Review Comment:
   This new branch for rebuilding range indexes from a raw forward index plus 
shared dictionary is not covered by any added test. The PR adds end-to-end 
reload tests for inverted/FST/IFST, but nothing exercises this path, so a 
mismatch between raw-value reads and dict-id emission here would only show up 
in production reloads.



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