From 5dcdb5a75a970d354c34cd91e94dcbd554bcd72e Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 26 May 2024 10:52:04 -0400 Subject: [PATCH] Restored checks [skip ci] --- src/hnswutils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hnswutils.c b/src/hnswutils.c index f78608b..d3ba911 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -806,9 +806,16 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F if (eDistance < f->distance || wlen < ef) { - /* Copy e */ - HnswCandidate *ec = palloc(sizeof(HnswCandidate)); + HnswCandidate *ec; + Assert(!eElement->deleted); + + /* Make robust to issues */ + if (eElement->level < lc) + continue; + + /* Copy e */ + ec = palloc(sizeof(HnswCandidate)); HnswPtrStore(base, ec->element, eElement); ec->distance = eDistance;