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


##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataFetcher.java:
##########
@@ -324,13 +327,20 @@ private class ColumnValueReader implements AutoCloseable {
     final Dictionary _dictionary;
     final DataType _storedType;
     final boolean _singleValue;
+    final boolean _useDictionary;

Review Comment:
   (minor) `_dictionaryEncoded` is more clear



##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataFetcher.java:
##########
@@ -345,13 +355,20 @@ private ForwardIndexReaderContext getReaderContext() {
 
     void readDictIds(int[] docIds, int length, int[] dictIdBuffer) {
       Tracing.activeRecording().setInputDataType(_storedType, _singleValue);
-      _reader.readDictIds(docIds, length, dictIdBuffer, getReaderContext());
+      ForwardIndexReaderContext readerContext = getReaderContext();
+      if (_useDictionary) {
+        _reader.readDictIds(docIds, length, dictIdBuffer, readerContext);
+      } else {
+        Preconditions.checkState(_dictionary != null, "Dictionary must be 
present for raw forward index");
+        Preconditions.checkState(_singleValue, "readDictIds(int[]) is 
single-value only; use readDictIdsMV for MV");
+        readDictIdsFromRawValues(docIds, length, dictIdBuffer, readerContext);

Review Comment:
   This will be very expensive. Do we want to allow this? Or only allow 
explicitly calling `readDictIdsFromRawValues()`



##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataFetcher.java:
##########
@@ -80,7 +81,9 @@ public void addDataSource(String column, DataSource 
dataSource) {
     ForwardIndexReader<?> forwardIndexReader = dataSource.getForwardIndex();
     Preconditions.checkState(forwardIndexReader != null,
         "Forward index disabled for column: %s, cannot create DataFetcher!", 
column);
-    ColumnValueReader columnValueReader = new 
ColumnValueReader(forwardIndexReader, dataSource.getDictionary());
+    Dictionary dictionary = dataSource.getDictionary();
+    boolean useDictionary = forwardIndexReader.isDictionaryEncoded() && 
dictionary != null;

Review Comment:
   Is it possible that forward index is dictionary encoded by dictionary 
doesn't exist?



##########
pinot-core/src/main/java/org/apache/pinot/core/common/DataFetcher.java:
##########
@@ -345,13 +355,20 @@ private ForwardIndexReaderContext getReaderContext() {
 
     void readDictIds(int[] docIds, int length, int[] dictIdBuffer) {
       Tracing.activeRecording().setInputDataType(_storedType, _singleValue);
-      _reader.readDictIds(docIds, length, dictIdBuffer, getReaderContext());
+      ForwardIndexReaderContext readerContext = getReaderContext();
+      if (_useDictionary) {
+        _reader.readDictIds(docIds, length, dictIdBuffer, readerContext);
+      } else {
+        Preconditions.checkState(_dictionary != null, "Dictionary must be 
present for raw forward index");

Review Comment:
   Don't do this in hot path. This shouldn't be possible. Same for other places



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