Introduce TermGroupFacetCollectorManager for concurrent grouped faceting#16292
Open
javanna wants to merge 3 commits into
Open
Introduce TermGroupFacetCollectorManager for concurrent grouped faceting#16292javanna wants to merge 3 commits into
javanna wants to merge 3 commits into
Conversation
The old TermGroupFacetCollector could not be adapted to CollectorManager: its cross-segment deduplication was fundamentally sequential. At doSetNextReader(), all previously seen (group, facet) pairs were re-looked up in each new segment's ordinal dictionary to rebuild the per-segment SentinelIntSet. That O(pairs × segments) walk cannot be split across concurrent slices, and every unique hit allocated a BytesRef copy in the collection hot path. The replacement design tracks (groupOrd, facetOrd) pairs as packed longs in a per-slice LongHashSet during collection — no BytesRef allocations in the hot path. Ordinals are translated to terms once per segment in LeafCollector.finish(), and reduce() performs global deduplication across all slices via a HashSet<GroupFacetPair>, correctly counting groups whose documents span multiple search slices. All 8 deprecated IndexSearcher#search(Query, Collector) call sites in TestGroupFacetCollector are removed as a result. TermGroupFacetCollector is now deprecated in favour of TermGroupFacetCollectorManager The base class GroupFacetCollector is also now deprecated. Relates to apache#12892.
javanna
commented
Jun 24, 2026
| * | ||
| * @lucene.experimental | ||
| */ | ||
| public class GroupedFacetResult { |
Contributor
Author
There was a problem hiding this comment.
This is temporarily duplicated: same code is also in within the now deprecated GroupFacetCollector. The idea is to backport this change cleanly to 10.x, then remove the deprecated classes from main.
19 tasks
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.
The old TermGroupFacetCollector could not be adapted to CollectorManager:
its cross-segment deduplication was fundamentally sequential. At
doSetNextReader(), all previously seen (group, facet) pairs were
re-looked up in each new segment's ordinal dictionary to rebuild the
per-segment SentinelIntSet. That O(pairs × segments) walk cannot be
split across concurrent slices, and every unique hit allocated a
BytesRef copy in the collection hot path.
The replacement design tracks (groupOrd, facetOrd) pairs as packed
longs in a per-slice LongHashSet during collection — no BytesRef
allocations in the hot path. Ordinals are translated to terms once per
segment in LeafCollector.finish(), and reduce() performs global
deduplication across all slices via a HashSet,
correctly counting groups whose documents span multiple search slices.
All 8 deprecated IndexSearcher#search(Query, Collector) call sites in
TestGroupFacetCollector are removed as a result.
TermGroupFacetCollector is now deprecated in favour of TermGroupFacetCollectorManager
The base class GroupFacetCollector is also now deprecated.
Relates to #12892.