diff --git a/src/hnswutils.c b/src/hnswutils.c index be162fa..f105ea6 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -1,5 +1,6 @@ #include "postgres.h" +#include #include #include "access/generic_xlog.h" @@ -573,7 +574,14 @@ HnswLoadElementImpl(BlockNumber blkno, OffsetNumber offno, float *distance, Datu if (DatumGetPointer(*q) == NULL) *distance = 0; else + { *distance = (float) DatumGetFloat8(FunctionCall2Coll(procinfo, collation, *q, PointerGetDatum(&etup->data))); + + /* Needed for intvec cosine distance */ + /* TODO Improve */ + if (isnan(*distance)) + *distance = FLT_MAX; + } } /* Load element */ diff --git a/src/intvec.c b/src/intvec.c index 540782b..79bfed2 100644 --- a/src/intvec.c +++ b/src/intvec.c @@ -110,7 +110,7 @@ intvec_in(PG_FUNCTION_ARGS) int8 x[INTVEC_MAX_DIM]; int dim = 0; char *pt = lit; - IntVector *result; + IntVector *result; while (intvec_isspace(*pt)) pt++;