Skip to content

Commit

Permalink
use soft-deleted points
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhu committed Oct 2, 2023
1 parent 7716875 commit b9803e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions datasketch/hnsw.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ def _repair_connections(
entry_point,
entry_point_dist,
layer,
allow_soft_deleted=False,
# We allow soft-deleted points to be returned and used as entry point.
allow_soft_deleted=True,
key_to_hard_delete=key_to_delete,
)
entry_points = [(-entry_point_dist, entry_point)]
Expand All @@ -626,7 +627,9 @@ def _repair_connections(
entry_points,
layer,
ef + 1, # We add 1 to ef to account for the point itself.
allow_soft_deleted=False,
# We allow soft-deleted points to be returned and used as entry point
# and neighbor candidates.
allow_soft_deleted=True,
key_to_hard_delete=key_to_delete,
)
# Filter out the updated node itself.
Expand Down
1 change: 0 additions & 1 deletion test/test_hnsw.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def test_soft_remove_and_pop_and_clean(self):
"Potential graph connectivity issue."
)
# NOTE: we are not getting the expected number of results.
# This may be because the graph is not connected anymore.
# Try hard remove all previous soft removed points.
hnsw.clean()
results = hnsw.query(data[i], 10)
Expand Down

0 comments on commit b9803e8

Please sign in to comment.