Merge branch 'master' into hnsw-streaming

This commit is contained in:
Andrew Kane
2024-09-20 15:24:27 -07:00

View File

@@ -884,7 +884,6 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
HnswPairingHeapNode *node; HnswPairingHeapNode *node;
float eDistance; float eDistance;
bool alwaysAdd = wlen < ef; bool alwaysAdd = wlen < ef;
bool discard;
f = HnswGetPairingHeapCandidate(w_node, pairingheap_first(W)); f = HnswGetPairingHeapCandidate(w_node, pairingheap_first(W));
@@ -892,8 +891,6 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
{ {
eElement = unvisited[i].element; eElement = unvisited[i].element;
eDistance = GetElementDistance(base, eElement, q, procinfo, collation); eDistance = GetElementDistance(base, eElement, q, procinfo, collation);
discard = !(eDistance < f->distance || alwaysAdd);
} }
else else
{ {
@@ -904,11 +901,9 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
/* Avoid any allocations if not adding */ /* Avoid any allocations if not adding */
eElement = NULL; eElement = NULL;
HnswLoadElementImpl(blkno, offno, &eDistance, &q, index, procinfo, collation, inserting, alwaysAdd || discarded != NULL ? NULL : &f->distance, &eElement); HnswLoadElementImpl(blkno, offno, &eDistance, &q, index, procinfo, collation, inserting, alwaysAdd || discarded != NULL ? NULL : &f->distance, &eElement);
discard = eElement == NULL || !(eDistance < f->distance || alwaysAdd);
} }
if (discard) if (eElement == NULL || !(eDistance < f->distance || alwaysAdd))
{ {
if (discarded != NULL) if (discarded != NULL)
{ {