feat: filter index rows before top-k - #1111
Merged
Merged
Conversation
shirly121
reviewed
Sep 22, 2026
| namespace neug::fts_ext { | ||
| namespace { | ||
|
|
||
| struct IndexFilter { |
Collaborator
There was a problem hiding this comment.
这里直接传一个 const 引用吧,用指针感觉会有生命周期管理风险
| std::unordered_set<index_id_t> allowed; | ||
| bool use_scalar_filter{false}; | ||
|
|
||
| bool Accepts(index_id_t index_id) const { |
Collaborator
There was a problem hiding this comment.
建议这个接口定义成 bool operator()(index_id_t index_id) const {}
| } | ||
| }; | ||
|
|
||
| void DestroyIndexFilter(void* filter) { |
Collaborator
There was a problem hiding this comment.
为什么要实现 delete 呢?这里不应该管理 IndexIDAccessor 生命周期
Collaborator
Author
There was a problem hiding this comment.
这里delete的是IndexFilter这个类的指针
| bool use_scalar_filter{false}; | ||
|
|
||
| bool Accepts(index_id_t index_id) const { | ||
| if (use_scalar_filter) { |
Collaborator
There was a problem hiding this comment.
我感觉这里要不实现成两个不同的类:例如:ScalarFilter or MVCCFilter。这里混在一个接口里实现有些语义不清
shirly121
reviewed
Sep 22, 2026
| try { | ||
| // Convert the streaming scalar filter to a hash set for fast filtering. | ||
| std::unordered_set<index_id_t> allowed; | ||
| auto index_filter = std::make_unique<IndexFilter>(); |
Collaborator
There was a problem hiding this comment.
为没有数据修改且没有标量过滤场景提供优化,避免产生 IndexFilter
Collaborator
Author
There was a problem hiding this comment.
额外增加了两组prepared statement,当index内所有数据都有效时,不再使用filtering,直接使用下推的limit。
11d090b
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.
Summary
index_filterscalar function on the SQLite FTS connectionLIMITinto the FTS query while preserving deterministic row-ID tie-breakingTesting
The incremental FTS build completed successfully before the change was moved onto this standalone branch. Per request, it was not rebuilt after the branch split and no additional tests were added.
Fixes #1106