mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 14:46:56 +08:00
Ensure order is deterministic for SelectNeighbors closer caching
This commit is contained in:
@@ -887,6 +887,12 @@ CompareCandidateDistances(const void *a, const void *b)
|
|||||||
if (hca->distance > hcb->distance)
|
if (hca->distance > hcb->distance)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (hca->element < hcb->element)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (hca->element > hcb->element)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1048,6 +1054,10 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
|
|||||||
else
|
else
|
||||||
lw = w;
|
lw = w;
|
||||||
|
|
||||||
|
/* Ensure order is deterministic for SelectNeighbors closer caching */
|
||||||
|
if (index == NULL)
|
||||||
|
list_sort(lw, CompareCandidateDistances);
|
||||||
|
|
||||||
neighbors = SelectNeighbors(lw, lm, lc, procinfo, collation, element, NULL, NULL);
|
neighbors = SelectNeighbors(lw, lm, lc, procinfo, collation, element, NULL, NULL);
|
||||||
|
|
||||||
AddConnections(element, neighbors, lm, lc);
|
AddConnections(element, neighbors, lm, lc);
|
||||||
|
|||||||
Reference in New Issue
Block a user