clintropolis commented on a change in pull request #8822: optimize numeric 
column null value checking for low filter selectivity (more rows)
URL: https://github.com/apache/incubator-druid/pull/8822#discussion_r344078217
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/druid/segment/vector/VectorSelectorUtils.java
 ##########
 @@ -47,14 +47,38 @@
       retVal = new boolean[offset.getMaxVectorSize()];
     }
 
-    // Probably not super efficient to call "get" so much, but, no worse than 
the non-vectorized version.
+    int nextNullRow = nullIterator.next();
     if (offset.isContiguous()) {
+      final int startOffset = offset.getStartOffset();
+      nullIterator.advanceIfNeeded(startOffset);
       for (int i = 0; i < offset.getCurrentVectorSize(); i++) {
-        retVal[i] = nullValueBitmap.get(i + offset.getStartOffset());
+        final int row = i + startOffset;
+        if (row == nextNullRow) {
+          retVal[i] = true;
+          if (nullIterator.hasNext()) {
+            nextNullRow = nullIterator.next();
+          } else {
+            break;
+          }
+        } else {
+          retVal[i] = false;
+        }
       }
     } else {
+      final int[] currentOffsets = offset.getOffsets();
+      nullIterator.advanceIfNeeded(currentOffsets[0]);
       for (int i = 0; i < offset.getCurrentVectorSize(); i++) {
-        retVal[i] = nullValueBitmap.get(offset.getOffsets()[i]);
+        final int row = currentOffsets[i];
+        if (row == nextNullRow) {
 
 Review comment:
   You were correct on this, I have fixed the implementation to only use 
`advanceIfNeeded` and `peekNext` which I think makes it a bit easier to follow, 
though maybe not quite as optimal since it might result in a few additional 
`advanceIfNeeded` operations. I also added tests for this method that catch 
this, since it wasn't actually covered otherwise previously.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to