clintropolis commented on code in PR #13561:
URL: https://github.com/apache/druid/pull/13561#discussion_r1049213657


##########
processing/src/main/java/org/apache/druid/segment/nested/NestedFieldLiteralColumnIndexSupplier.java:
##########
@@ -336,17 +336,21 @@ public BitmapColumnIndex forValue(@Nullable String value)
         @Override
         public double estimateSelectivity(int totalRows)
         {
-          return (double) getBitmap(
-              
localDictionary.indexOf(stringDictionary.indexOf(StringUtils.toUtf8ByteBuffer(value)))
-          ).size() / totalRows;
+          final int globalId = 
stringDictionary.indexOf(StringUtils.toUtf8ByteBuffer(value));
+          if (globalId < 0) {
+            return 0.0;
+          }
+          return (double) getBitmap(localDictionary.indexOf(globalId)).size() 
/ totalRows;
         }
 
         @Override
         public <T> T computeBitmapResult(BitmapResultFactory<T> 
bitmapResultFactory)
         {
-          return bitmapResultFactory.wrapDimensionValue(
-              
getBitmap(localDictionary.indexOf(stringDictionary.indexOf(StringUtils.toUtf8ByteBuffer(value))))
-          );
+          final int globalId = 
stringDictionary.indexOf(StringUtils.toUtf8ByteBuffer(value));
+          if (globalId < 0) {
+            return 
bitmapResultFactory.wrapDimensionValue(bitmapFactory.makeEmptyImmutableBitmap());
+          }
+          return 
bitmapResultFactory.wrapDimensionValue(getBitmap(localDictionary.indexOf(globalId)));

Review Comment:
   i might make sense to remain in `Filter` since the 'and'/'or' filters are 
the only ones that really do anything besides get the size of the bitmap and 
divide by number of rows.
   
   I think refactoring this right now is a bit too much for this bug fix and 
I'd rather do as a follow-up, is that ok?



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