HBASE-30150: Delegate getHintForRejectedRow and getSkipHint in composite filters.#8217
Open
shubham-roy wants to merge 3 commits into
Open
HBASE-30150: Delegate getHintForRejectedRow and getSkipHint in composite filters.#8217shubham-roy wants to merge 3 commits into
shubham-roy wants to merge 3 commits into
Conversation
…ite filters FilterList (AND/OR), SkipFilter, and WhileMatchFilter now delegate getHintForRejectedRow() and getSkipHint() to their sub-filters, using maximal-step merging for AND and minimal-step merging for OR — consistent with the existing getNextCellHint() convention. ColumnRangeFilter and ColumnPrefixFilter gain stateless getSkipHint() implementations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nd strengthen test coverage - Add getSkipHint() to MultipleColumnPrefixFilter so it participates in the structural-skip hint optimization alongside ColumnPrefixFilter and ColumnRangeFilter. - Add unit tests for the all-sub-filters-terminated edge case in both AND and OR FilterList for getHintForRejectedRow and getSkipHint. - Add integration test for MultipleColumnPrefixFilter.getSkipHint with time-range gating. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…HintForRejectedRow - Track which sub-filters actually rejected via filterRowKey() using a boolean[] rejectedByFilterRowKey array (mirrors seekHintFilters pattern). getHintForRejectedRow now only consults sub-filters that individually returned true from filterRowKey, honouring the per-filter contract. - Clarify Filter.java javadoc: OR's null-collapse semantic is now explicitly documented for both getHintForRejectedRow and getSkipHint. - Add unit test proving the contract: a non-rejecting sub-filter that throws IllegalStateException from getHintForRejectedRow is never called. - Add divergent-hint tests (unit + integration) asserting AND correctly returns max when sub-filters hint to different targets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HBASE-30150: Delegate getHintForRejectedRow and getSkipHint in composite filters
Problem
HBASE-29974 introduced two new filter optimization methods —
getHintForRejectedRowandgetSkipHint— that allow filters to provide seek hints to thescan pipeline. However, composite filter wrappers (
FilterList,SkipFilter,WhileMatchFilter) did not delegate these methods to their sub-filters.Hints from sub-filters were silently discarded, severely limiting the optimization's practical impact.
Solution
Implement delegation for both methods in all composite filter wrappers:
FilterList (AND / MUST_PASS_ALL):
getHintForRejectedRow: Maximal step — returns the farthest hint among sub-filters that actually rejected the row viafilterRowKey. Onlysub-filters whose
filterRowKeyreturnedtrueare consulted, honouring the per-filter contract. Null hints are ignored.getSkipHint: Maximal step — returns the farthest hint among all sub-filters. Null hints are ignored.FilterList (OR / MUST_PASS_ONE):
getHintForRejectedRow: Minimal step — returns the nearest hint. If any non-terminated sub-filter returns null, the composite returns null (cannotsafely skip).
getSkipHint: Same minimal-step semantic with null-collapse.SkipFilter / WhileMatchFilter: Simple passthrough delegation to the wrapped filter.
Leaf filter
getSkipHintimplementations:ColumnPrefixFilter: Delegates togetNextCellHintwith null-prefix guard.ColumnRangeFilter: Delegates togetNextCellHintwith null-minColumn guard.MultipleColumnPrefixFilter: Recomputes the correct target prefix fromsortedPrefixesstatelessly (cannot reuse the mutablehintfield sincefilterCellwas never called on the structural-skip path).Scan direction handling
All composite merging uses
FilterListBase.compareCell()which negates the comparison whenreversed == true. This means "max" in AND correctly becomesthe smallest row key in reverse scan, and "min" in OR becomes the largest. Unit and integration tests explicitly verify reversed-scan behavior for both
AND and OR, for both APIs.
Contract compliance (FilterListWithAND)
rejectedByFilterRowKey
array (mirroring the existingseekHintFilterspattern used bygetNextCellHint). Only those sub-filters are consulted for hints, honouring theFilter.java` contract: "Only called after filterRowKey(Cell) has returned true for the same firstRowCell."This does not apply to
getSkipHint, whose contract explicitly permits being called on cells the filter never saw.Test coverage
Unit tests (
TestFilterListHintDelegation) — 36 tests:getHintForRejectedRow/getSkipHint× forward/reversed/null/all-null/single/empty/terminatedIntegration tests (
TestFilterHintForRejectedRow) — 26 tests:ColumnRangeFilter,ColumnPrefixFilter,MultipleColumnPrefixFiltergetSkipHintwith time-range gatinggetSkipHintcompositionFiles changed
Filter.javaFilterList.javafilterListBaseFilterListWithAND.javarejectedByFilterRowKeytrackingFilterListWithOR.javaSkipFilter.javaWhileMatchFilter.javaColumnPrefixFilter.javagetSkipHintwith null-prefix guardColumnRangeFilter.javagetSkipHintwith null-minColumn guardMultipleColumnPrefixFilter.javagetSkipHintrecomputing target fromsortedPrefixesTestFilterListHintDelegation.javaTestFilterHintForRejectedRow.java