fix(vector): preserve HNSW connectivity when replacing vectors - #375
Open
jarmen423 wants to merge 1 commit into
Open
fix(vector): preserve HNSW connectivity when replacing vectors#375jarmen423 wants to merge 1 commit into
jarmen423 wants to merge 1 commit into
Conversation
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
NodeIdas vector replacementFixes #374.
Problem
GrafeoDB::set_node_property()auto-syncs vector indexes by callinginsert()even when the node is already indexed.HnswIndex::insert()previously overwrote that node's topology entry with fresh empty neighbor lists while other nodes retained reciprocal links to the old entry. Depending on the randomized HNSW level, this could make unrelated nodes unreachable.A simple
remove()followed byinsert()prevents stale links but can still disconnect the removed node's former neighborhoods when it was a bridge. This patch reconnects those former neighbors at each shared layer, prunes them to the configured degree, and then performs normal insertion for the replacement vector.Verification
The vector incremental suite passes 10/10 tests, including 60 fresh-database repeated-update iterations and a changed-vector replacement case.
Summary by cubic
Preserves HNSW connectivity when updating vectors via
set_node_property(), preventing stale links and unreachable nodes. Adds neighbor reconnection and pruning during replacement, plus regression tests to ensure full reachability.NodeIdas a replacement: remove the old topology and drop stale reciprocal links.m/m_max; reinsert the new vector and update the entry point if needed.Written for commit 23102d7. Summary will update on new commits.