Skip to content

Implement canProduceBitmaps and getBitmaps for AND and OR filter operators - #19038

Merged
Jackie-Jiang merged 1 commit into
apache:masterfrom
Jackie-Jiang:filter-and-or-bitmaps
Jul 22, 2026
Merged

Implement canProduceBitmaps and getBitmaps for AND and OR filter operators#19038
Jackie-Jiang merged 1 commit into
apache:masterfrom
Jackie-Jiang:filter-and-or-bitmaps

Conversation

@Jackie-Jiang

Copy link
Copy Markdown
Contributor

Summary

Implements canProduceBitmaps and getBitmaps for AndFilterOperator and OrFilterOperator, which previously fell back to the base BaseFilterOperator defaults (canProduceBitmaps() returning false and getBitmaps() throwing).

  • canProduceBitmaps() returns true only when every child can produce bitmaps.
  • getBitmaps() reduces each child's BitmapCollection — so any per-child inversion (exclusive predicates, NOT) is materialized before aggregation — then combines them via BufferFastAggregation.and (AND) / BufferFastAggregation.or (OR), returning a non-inverted single-bitmap BitmapCollection.
  • canOptimizeCount() now delegates to canProduceBitmaps() in both operators, removing the duplicated "all children can produce bitmaps" loop it previously carried.

This lets composite AND/OR nodes participate directly in the bitmap-based fast paths (e.g. count optimization and getFilteredDocIds) instead of being materialized through document iteration, and it composes recursively for nested AND/OR trees.

FilterOperatorUtils strips MatchAllFilterOperator / EmptyFilterOperator children before constructing an AND/OR, so every child of an AND/OR shares the same numDocs, making the reduce-then-aggregate path safe.

@Jackie-Jiang Jackie-Jiang added bug Something is not working as expected query Related to query processing labels Jul 22, 2026
@Jackie-Jiang
Jackie-Jiang requested review from Copilot and xiangfu0 July 22, 2026 01:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables bitmap production for composite AndFilterOperator and OrFilterOperator in pinot-core, allowing AND/OR nodes to participate directly in bitmap-based fast paths (e.g., count optimization and getFilteredDocIds) instead of falling back to doc iteration.

Changes:

  • Implement canProduceBitmaps() and getBitmaps() for AndFilterOperator and OrFilterOperator by reducing each child’s BitmapCollection and aggregating via BufferFastAggregation.and/or.
  • Simplify canOptimizeCount() in both operators to delegate to canProduceBitmaps().
  • Add unit tests covering bitmap capability and bitmap aggregation (including exclusive/inverted children and nesting), plus minor test cleanups.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/AndFilterOperator.java Adds bitmap capability for composite AND filters and aligns canOptimizeCount() with bitmap support.
pinot-core/src/main/java/org/apache/pinot/core/operator/filter/OrFilterOperator.java Adds bitmap capability for composite OR filters and aligns canOptimizeCount() with bitmap support.
pinot-core/src/test/java/org/apache/pinot/core/operator/filter/AndFilterOperatorTest.java Adds tests validating canProduceBitmaps()/getBitmaps() behavior for AND, including exclusive and nested cases.
pinot-core/src/test/java/org/apache/pinot/core/operator/filter/OrFilterOperatorTest.java Adds tests validating canProduceBitmaps()/getBitmaps() behavior for OR, including exclusive and nested cases; also updates assertions/imports.

@codecov-commenter

codecov-commenter commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.44%. Comparing base (385e38a) to head (1de9744).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19038      +/-   ##
============================================
- Coverage     65.45%   65.44%   -0.01%     
  Complexity     1421     1421              
============================================
  Files          3428     3428              
  Lines        216598   216608      +10     
  Branches      34311    34313       +2     
============================================
- Hits         141778   141763      -15     
- Misses        63405    63435      +30     
+ Partials      11415    11410       -5     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 65.44% <100.00%> (-0.01%) ⬇️
temurin 65.44% <100.00%> (-0.01%) ⬇️
unittests 65.44% <100.00%> (-0.01%) ⬇️
unittests1 56.88% <100.00%> (-0.03%) ⬇️
unittests2 37.73% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ators

AndFilterOperator and OrFilterOperator now override canProduceBitmaps
(true when every child can produce bitmaps) and getBitmaps (intersection
for AND, union for OR, reducing each child so per-child inversion is
honored). canOptimizeCount now delegates to canProduceBitmaps, removing
the duplicated all-children-can-produce-bitmaps loop.
@Jackie-Jiang
Jackie-Jiang force-pushed the filter-and-or-bitmaps branch from ab1cbb1 to 1de9744 Compare July 22, 2026 06:37
@Jackie-Jiang
Jackie-Jiang merged commit bde7223 into apache:master Jul 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working as expected query Related to query processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants