Skip to content

[core] Stabilize scored global index top-k tie-breaking#8301

Merged
JingsongLi merged 1 commit into
apache:masterfrom
QuakeWang:fix-topk-ties
Jun 22, 2026
Merged

[core] Stabilize scored global index top-k tie-breaking#8301
JingsongLi merged 1 commit into
apache:masterfrom
QuakeWang:fix-topk-ties

Conversation

@QuakeWang

Copy link
Copy Markdown
Member

Purpose

ScoredGlobalIndexResult.topK used a min-heap ordered only by score, and replaced the heap head only when a new row had a strictly higher score. When rows tied around the top-k boundary, the retained row IDs could differ from the expected score desc, rowId asc ranking semantics.

This patch makes the heap head represent the weakest retained candidate by score asc, rowId desc, so tied boundary rows prefer smaller row IDs while keeping the existing O(n log k) algorithm.

Tests

  • mvn -pl paimon-common -Dtest=ScoredGlobalIndexResultTest,HybridSearchRankerTest test

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit 8b2911b into apache:master Jun 22, 2026
13 of 15 checks passed
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