Skip to content

[core] Optimize BTree negative predicate complement - #8945

Open
zhoulii wants to merge 1 commit into
apache:masterfrom
zhoulii:paimon-btree-negative-predicate-complement
Open

[core] Optimize BTree negative predicate complement#8945
zhoulii wants to merge 1 commit into
apache:masterfrom
zhoulii:paimon-btree-negative-predicate-complement

Conversation

@zhoulii

@zhoulii zhoulii commented Jul 30, 2026

Copy link
Copy Markdown
Member

Purpose

close #8944

Tests

}

@Override
public boolean supportsRangeComplement() {

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.

Can we just implement methods in this class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean overriding visitIsNotNull, visitNotEqual, and visitNotIn directly in LazyFilteredBTreeReader?

The challenge is that LazyFilteredBTreeReader only has the index files and local row IDs, but it does not know the complete row-id range of the shard. A correct complement requires this full range, which is currently only available in OffsetGlobalIndexReader as [offset, to].

Implementing the complement directly in LazyFilteredBTreeReader would either require reading all BTree files to reconstruct the full row-id set, which defeats this optimization, or passing the row range through GlobalIndexer#createReader.

That is why the current implementation computes the complement in OffsetGlobalIndexReader and lets LazyFilteredBTreeReader opt in through supportsRangeComplement().

}

@Override
public boolean supportsRangeComplement() {

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.

Bitmap also supports this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, technically Bitmap can also use the range-complement path.

However, the benefit is generally smaller than for BTree. Bitmap already stores nonNullRows as a bitmap, making per-file negative evaluation cheap, while BTree must scan all non-null key entries and row IDs in each selected file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Optimize BTree global index reads for negative predicates

2 participants