mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 00:26:55 +08:00
Improved logic for pruning elements
This commit is contained in:
@@ -859,8 +859,8 @@ UpdateConnections(HnswElement element, List *neighbors, int m, int lc, List **up
|
|||||||
else
|
else
|
||||||
hc3->distance = GetCandidateDistance(hc3, q, procinfo, collation);
|
hc3->distance = GetCandidateDistance(hc3, q, procinfo, collation);
|
||||||
|
|
||||||
/* Prune deleted element */
|
/* Prune element if being deleted */
|
||||||
if (hc3->element->deleted)
|
if (list_length(hc3->element->heaptids) == 0)
|
||||||
{
|
{
|
||||||
pruned = ¤tNeighbors->items[i];
|
pruned = ¤tNeighbors->items[i];
|
||||||
break;
|
break;
|
||||||
@@ -868,14 +868,14 @@ UpdateConnections(HnswElement element, List *neighbors, int m, int lc, List **up
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add and sort candidates */
|
|
||||||
for (int i = 0; i < currentNeighbors->length; i++)
|
|
||||||
c = lappend(c, ¤tNeighbors->items[i]);
|
|
||||||
c = lappend(c, &hc2);
|
|
||||||
list_sort(c, CompareCandidateDistances);
|
|
||||||
|
|
||||||
if (pruned == NULL)
|
if (pruned == NULL)
|
||||||
{
|
{
|
||||||
|
/* Add and sort candidates */
|
||||||
|
for (int i = 0; i < currentNeighbors->length; i++)
|
||||||
|
c = lappend(c, ¤tNeighbors->items[i]);
|
||||||
|
c = lappend(c, &hc2);
|
||||||
|
list_sort(c, CompareCandidateDistances);
|
||||||
|
|
||||||
SelectNeighbors(c, m, lc, procinfo, collation, &pruned);
|
SelectNeighbors(c, m, lc, procinfo, collation, &pruned);
|
||||||
|
|
||||||
/* Should not happen */
|
/* Should not happen */
|
||||||
|
|||||||
Reference in New Issue
Block a user