Skip to content

[fix](inverted index) Exclude MoW light deletes from BM25 statistics - #69403

Open
Authorlove wants to merge 1 commit into
apache:masterfrom
Authorlove:fix/bm25-visible-statistics
Open

Authorlove wants to merge 1 commit into
apache:masterfrom
Authorlove:fix/bm25-visible-statistics

Conversation

@Authorlove

@Authorlove Authorlove commented Oct 21, 2026 •

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: None

Related PR: #69352, #69438

MoW light deletes use versioned DELETE predicates. The storage reader filters their rows, but BM25 collection statistics only exclude delete-bitmap and delete-sign rows. The same visible documents therefore score differently from an independently loaded MoW table before compaction.

Extend the existing tablet-wide statistics collection with the captured DELETE predicates. Reuse DeleteHandler for current and historical column identities, compound/NULL predicate semantics and the query/rowset version boundaries. Read only the referenced columns in bounded batches and union filtered row IDs with the existing hidden set. The existing document-count, term-frequency and norms-sum corrections then apply unchanged to CLucene and SNII, including prefix expansion.

This keeps the existing shared-statistics mechanism, per-scanner derived caches and MoW norms-based avgdl. It adds no exact-length cache or raw-text tokenization. A newer insert is not hidden by an older DELETE. Scans with no DELETE predicates require no additional column reads.

Scope: MoW with its normal delete bitmap. DUP/MOR tables and the independent skip_delete_sign/show_hidden_columns issue are outside this change. DUP currently uses exact token totals, so extending its visibility statistics requires a separate decision about preserving that scoring contract; it must not silently switch to norms only while predicates exist.

Release note

Correct BM25 statistics on merge-on-write tables after light deletes, without waiting for compaction.

Check List (For Author)

  • 93 selected ASAN tests passed in CollectionStatisticsTest, CollectionStatisticsDetailedTest, CollectionStatisticsHiddenRowsTest, TabletCollectionStatisticsTest and ScoringDeletePredicatesTest. The three new real-segment cases cover batch boundaries, overlap with bitmap rows, historical column UIDs and query/rowset version bounds.
  • Built the master FE and the patched ASAN BE through build.sh, using baseline 8e10b23. No FE source or persisted format changes; optional BE Java extensions disabled locally.
  • test_bm25_score_light_delete_statistics passes on that cluster: V2/V3 with support_phrase=true/false and SNII with support_phrase=true; compound and NULL predicates, inserts after a delete, overlapping overwrite/delete histories, all-hidden/refill and serial/forced-parallel scans.
  • Existing test_bm25_score_parallel_scan_statistics and test_bm25_score_replica_statistics pass on the same cluster. This is a single-BE test cluster; the replica suite's multi-replica-only steps are not exercised locally.
  • The same new regression fails on the uncorrected query path at its first score comparison. This was also reproduced on a freshly built pure-master ASAN BE at the same frozen baseline and with the same master FE.
  • clang-format 16, build hygiene, and changed-line clang-tidy on all modified C++ source/test code passed.
  • Behavior changed: Yes. Light-deleted rows no longer affect MoW BM25 scores.
  • Does this need documentation: No new configuration or syntax.

Cost and remaining scope

The additional work reads the predicate columns of segments to which a captured light-delete predicate applies. It runs once per tablet through the existing holder. Added row-ID arrays use DorisVector and are disjoint from bitmap/sign rows before a linear merge. There is no new permanent cache, but query work and temporary memory grow with affected stored rows; no production performance claim is made.

@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?

@Authorlove
Authorlove force-pushed the fix/bm25-visible-statistics branch from b2ae44e to 53efe99 Compare October 21, 2026 12:52
### What problem does this PR solve?

Issue Number: None

Related PR: apache#69352, apache#69438, apache#69403

Problem Summary:
MoW light deletes filter rows through versioned DELETE predicates, but BM25
statistics only excluded delete-bitmap and delete-sign rows. Reuse DeleteHandler
with the captured read version and historical column identities to collect the
additional hidden row IDs. Read only predicate columns in bounded batches and
merge disjoint, tracked row-ID lists into the existing statistics path.
Keep the upstream tablet sharing, per-scanner caches and norms-based avgdl.

### Release note

Correct BM25 statistics after merge-on-write light deletes without waiting for
compaction.

### Check List (For Author)

- Test: 93 selected ASAN tests passed, including three real-segment predicate
  tests. Full-master SQL passed V2/V3 with phrase true/false and SNII with phrase
  true, including mutation phases and forced scanner splitting. Existing parallel
  scan and replica-statistics suites passed. The unfixed query path fails the new
  regression's initial score comparison. Format, hygiene and changed-line source
  and test clang-tidy passed.
- Behavior changed: Yes. Light-deleted rows no longer affect MoW BM25 statistics.
- Does this need documentation: No new configuration or syntax.
@Authorlove
Authorlove force-pushed the fix/bm25-visible-statistics branch from 53efe99 to 94bd985 Compare November 2, 2026 02:24
@Authorlove Authorlove changed the title [fix](be) Honor visible rows in CLucene BM25 statistics [fix](inverted index) Exclude MoW light deletes from BM25 statistics Nov 2, 2026
@Authorlove
Authorlove marked this pull request as ready for review November 2, 2026 07:55
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