Skip to content

fix(core - heap): prevent bypassing Heap invariants - #633

Open
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:codex/fix-heap-invariants
Open

fix(core - heap): prevent bypassing Heap invariants#633
JalinWang wants to merge 3 commits into
alibaba:mainfrom
JalinWang:codex/fix-heap-invariants

Conversation

@JalinWang

@JalinWang JalinWang commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Fix heap invariant violations caused by inherited std::vector mutation APIs.

  • Use Heap::emplace for group-by and brute-force search insertion.
  • Fix DiskANN initial group seeding to target the group heap.
  • Make Heap inherit privately and expose explicit read, mutation, and container access APIs.
  • Add coverage preventing implicit access to the underlying vector.

@JalinWang JalinWang changed the title Fix heap invariants in group search Use Heap::emplace to preserve heap invariants and limits Jul 30, 2026
@JalinWang JalinWang changed the title Use Heap::emplace to preserve heap invariants and limits fix(core): use Heap::emplace in groupby/bf search Jul 30, 2026
@JalinWang
JalinWang marked this pull request as ready for review July 30, 2026 06:17
@JalinWang
JalinWang requested a review from richyreachy as a code owner July 30, 2026 06:17
@JalinWang
JalinWang requested review from egolearner and iaojnh July 30, 2026 07:46

@egolearner egolearner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看下heap能改为private继承吗,否则外部还是容易误用

template <typename T, typename TCompare = std::less<T>,
          typename TBase = std::vector<T>>
class Heap : public TBase {

@JalinWang
JalinWang force-pushed the codex/fix-heap-invariants branch from ce5a13c to fdb8368 Compare August 10, 2026 11:32
@JalinWang
JalinWang requested a review from chinaux as a code owner August 10, 2026 11:32
@JalinWang

Copy link
Copy Markdown
Collaborator Author

看下heap能改为private继承吗,否则外部还是容易误用

template <typename T, typename TCompare = std::less<T>,
          typename TBase = std::vector<T>>
class Heap : public TBase {

done,顺带区分了一下mutable操作的api( mutable_at, mutable_container)

@egolearner egolearner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JalinWang JalinWang changed the title fix(core): use Heap::emplace in groupby/bf search fix(core - heap): prevent bypassing Heap invariants Aug 10, 2026
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