This is an automated email from the ASF dual-hosted git repository. gabor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/parquet-mr.git
The following commit(s) were added to refs/heads/master by this push: new c9cfe8214 PARQUET-2246: Add short circuit logic to column index filter. (#1030) c9cfe8214 is described below commit c9cfe821448a2f99797fda7f46c70a16cc1250a9 Author: Yujiang Zhong <42907416+zhongyuji...@users.noreply.github.com> AuthorDate: Thu Feb 23 21:36:46 2023 +0800 PARQUET-2246: Add short circuit logic to column index filter. (#1030) ColumnIndexFilter can be optimized by adding short-circuit logic to `AND` and `OR` operations. It's not necessary to evaluating the right node in some cases: - If the left result row ranges of `AND` is empty - If the left result row ranges of `OR` is full range of the row-group --- .../internal/filter2/columnindex/ColumnIndexFilter.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/ColumnIndexFilter.java b/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/ColumnIndexFilter.java index 6c27f9809..935c25942 100644 --- a/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/ColumnIndexFilter.java +++ b/parquet-column/src/main/java/org/apache/parquet/internal/filter2/columnindex/ColumnIndexFilter.java @@ -191,12 +191,22 @@ public class ColumnIndexFilter implements Visitor<RowRanges> { @Override public RowRanges visit(And and) { - return RowRanges.intersection(and.getLeft().accept(this), and.getRight().accept(this)); + RowRanges leftResult = and.getLeft().accept(this); + if (leftResult.getRanges().size() == 0) { + return leftResult; + } + + return RowRanges.intersection(leftResult, and.getRight().accept(this)); } @Override public RowRanges visit(Or or) { - return RowRanges.union(or.getLeft().accept(this), or.getRight().accept(this)); + RowRanges leftResult = or.getLeft().accept(this); + if (leftResult.getRanges().size() == 1 && leftResult.rowCount() == rowCount) { + return leftResult; + } + + return RowRanges.union(leftResult, or.getRight().accept(this)); } @Override