Skip to content

branch-4.1: [fix](inverted index) Split bound multi-segment readers #63138#65687

Open
airborne12 wants to merge 1 commit into
apache:branch-4.1from
airborne12:pick-63138-branch-4.1
Open

branch-4.1: [fix](inverted index) Split bound multi-segment readers #63138#65687
airborne12 wants to merge 1 commit into
apache:branch-4.1from
airborne12:pick-63138-branch-4.1

Conversation

@airborne12

Copy link
Copy Markdown
Member

What problem does this PR solve?

Cherry-pick #63138 to branch-4.1.

Issue Number: DORIS-25499

Problem Summary:
query_v2 search collection can drive segment iteration from readers.front() while leaf scorers resolve CLucene readers from reader_bindings or field_reader_bindings. If the actual leaf reader remains a multi-segment reader, SegmentPostings calls TermDocs::readBlock(), which CLucene does not support for multi-segment readers and can abort BE.

Release note

None

### What problem does this PR solve?

Issue Number: DORIS-25499

Related PR: None

Problem Summary:
query_v2 search collection can drive segment iteration from
`readers.front()` while leaf scorers resolve CLucene readers from
`reader_bindings` or `field_reader_bindings`. If the actual leaf reader
remains a multi-segment reader, `SegmentPostings` calls
`TermDocs::readBlock()`, which CLucene does not support for
multi-segment readers and can abort BE.

This PR selects the actual segmented reader from the execution context,
rewrites all readers and reader bindings to segment-level readers for
each callback, validates segmented reader topology, and keeps
`MultiSegmentReader` / `MultiReader` doc base handling explicit. It also
adds regression coverage for `MultiReader`, segmented field bindings,
and explicit single-reader binding keys.

### Release note

None

### Check List (For Author)

- Test
    - [x] Regression test
        - Added `MultiSegmentCollectorTest.CollectDocSetWithMultiReader`
- Added
`MultiSegmentCollectorTest.CollectDocSetWithSegmentedFieldBinding`
- Added `MultiSegmentCollectorTest.CollectDocSetWithSingleReaderBinding`
    - [x] Unit Test
- `env CCACHE_DIR=/tmp/doris25499-master-ccache
CCACHE_TEMPDIR=/tmp/doris25499-master-ccache-tmp ./run-be-ut.sh --run
--filter=MultiSegmentCollectorTest.* -j 32`
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason

- Behavior changed:
    - [x] No.
    - [ ] Yes.

- Does this need documentation?
    - [x] No.
    - [ ] Yes.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
@airborne12 airborne12 requested a review from yiguolei as a code owner July 16, 2026 05:41
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@airborne12

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 90.65% (97/107) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 54.97% (21112/38409)
Line Coverage 38.43% (202176/526039)
Region Coverage 34.83% (158786/455860)
Branch Coverage 35.83% (69365/193606)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 93.46% (100/107) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.26% (27126/37537)
Line Coverage 55.38% (289961/523578)
Region Coverage 52.83% (242532/459040)
Branch Coverage 53.96% (104633/193904)

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.

2 participants