pgvector.git / summary / log / commit / refs
commit ad7cad5ecd30ef58aa942b50256106913dc66d29
Author: Andrew Kane <andrew@ankane.org>
Date: Tue Jun 11 23:29:14 2024 +0000
Improved HnswSearchLayer code
src/hnswutils.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/hnswutils.c b/src/hnswutils.c
index 093e7efc..3eee0450 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -799,15 +799,16 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
{
float eDistance;
HnswElement eElement = HnswPtrAccess(base, e->element);
+ bool alwaysAdd = wlen < ef;
f = ((HnswPairingHeapNode *) pairingheap_first(W))->inner;
if (index == NULL)
eDistance = GetCandidateDistance(base, e, q, procinfo, collation);
else
- HnswLoadElement(eElement, &eDistance, &q, index, procinfo, collation, inserting, wlen >= ef ? &f->distance : NULL);
+ HnswLoadElement(eElement, &eDistance, &q, index, procinfo, collation, inserting, alwaysAdd ? NULL : &f->distance);
- if (eDistance < f->distance || wlen < ef)
+ if (eDistance < f->distance || alwaysAdd)
{
HnswCandidate *ec;
[parent: 2a8b9d689e5e]