gortiz commented on code in PR #10184: URL: https://github.com/apache/pinot/pull/10184#discussion_r1151589435
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/inverted/InvertedIndexType.java: ########## @@ -86,7 +130,46 @@ public String getFileExtension(ColumnMetadata columnMetadata) { } @Override - public String toString() { - return getId(); + public IndexHandler createIndexHandler(SegmentDirectory segmentDirectory, Map<String, FieldIndexConfigs> configsByCol, + @Nullable Schema schema, @Nullable TableConfig tableConfig) { + return new InvertedIndexHandler(segmentDirectory, configsByCol, tableConfig); + } + + public static class ReaderFactory implements IndexReaderFactory<InvertedIndexReader> { + public static final ReaderFactory INSTANCE = new ReaderFactory(); + + private ReaderFactory() { + } + + @Override + public InvertedIndexReader createIndexReader(SegmentDirectory.Reader segmentReader, + FieldIndexConfigs fieldIndexConfigs, ColumnMetadata metadata) + throws IOException, IndexReaderConstraintException { + if (fieldIndexConfigs == null || !fieldIndexConfigs.getConfig(StandardIndexes.inverted()).isEnabled()) { + return null; + } + if (!metadata.hasDictionary()) { + throw new IllegalStateException("Column " + metadata.getColumnName() + " cannot be indexed by an inverted " + + "index if it has no dictionary"); + } + if (metadata.isSorted() && metadata.isSingleValue()) { + ForwardIndexReader fwdReader = StandardIndexes.forward().getReaderFactory() + .createIndexReader(segmentReader, fieldIndexConfigs, metadata); + Preconditions.checkState(fwdReader instanceof SortedIndexReader); + return (SortedIndexReader) fwdReader; + } else { + return createSkippingForward(segmentReader, metadata); + } + } + + public InvertedIndexReader createSkippingForward(SegmentDirectory.Reader segmentReader, ColumnMetadata metadata) Review Comment: Because it skips the optimization where the forward index is used instead of the inverted when the column is sorted. Therefore this new method doesn't need to receive `FieldIndexConfigs fieldIndexConfigs` as parameter. I introduced this method recently in order to be able to call if from `InvertedIndexAndDictionaryBasedForwardIndexCreator`, where we actually need to want to create the forward index by reading the inverted one. -- 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