Skip to content

Commit 600ca5a

Browse files
committed
Improved logic for pruning elements
1 parent c17d515 commit 600ca5a

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/hnswutils.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -859,23 +859,23 @@ UpdateConnections(HnswElement element, List *neighbors, int m, int lc, List **up
859859
else
860860
hc3->distance = GetCandidateDistance(hc3, q, procinfo, collation);
861861

862-
/* Prune deleted element */
863-
if (hc3->element->deleted)
862+
/* Prune element if being deleted */
863+
if (list_length(hc3->element->heaptids) == 0)
864864
{
865865
pruned = &currentNeighbors->items[i];
866866
break;
867867
}
868868
}
869869
}
870870

871-
/* Add and sort candidates */
872-
for (int i = 0; i < currentNeighbors->length; i++)
873-
c = lappend(c, &currentNeighbors->items[i]);
874-
c = lappend(c, &hc2);
875-
list_sort(c, CompareCandidateDistances);
876-
877871
if (pruned == NULL)
878872
{
873+
/* Add and sort candidates */
874+
for (int i = 0; i < currentNeighbors->length; i++)
875+
c = lappend(c, &currentNeighbors->items[i]);
876+
c = lappend(c, &hc2);
877+
list_sort(c, CompareCandidateDistances);
878+
879879
SelectNeighbors(c, m, lc, procinfo, collation, &pruned);
880880

881881
/* Should not happen */

0 commit comments

Comments
 (0)