mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 15:46:54 +08:00
Fixed sort function for Postgres 12
This commit is contained in:
@@ -860,12 +860,15 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
|
|||||||
static int
|
static int
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
CompareCandidateDistances(const ListCell *a, const ListCell *b)
|
CompareCandidateDistances(const ListCell *a, const ListCell *b)
|
||||||
|
{
|
||||||
|
HnswCandidate *hca = lfirst(a);
|
||||||
|
HnswCandidate *hcb = lfirst(b);
|
||||||
#else
|
#else
|
||||||
CompareCandidateDistances(const void *a, const void *b)
|
CompareCandidateDistances(const void *a, const void *b)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
HnswCandidate *hca = lfirst((ListCell *) a);
|
HnswCandidate *hca = lfirst(*(ListCell **) a);
|
||||||
HnswCandidate *hcb = lfirst((ListCell *) b);
|
HnswCandidate *hcb = lfirst(*(ListCell **) b);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hca->distance < hcb->distance)
|
if (hca->distance < hcb->distance)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -888,12 +891,15 @@ CompareCandidateDistances(const void *a, const void *b)
|
|||||||
static int
|
static int
|
||||||
#if PG_VERSION_NUM >= 130000
|
#if PG_VERSION_NUM >= 130000
|
||||||
CompareCandidateDistancesOffset(const ListCell *a, const ListCell *b)
|
CompareCandidateDistancesOffset(const ListCell *a, const ListCell *b)
|
||||||
|
{
|
||||||
|
HnswCandidate *hca = lfirst(a);
|
||||||
|
HnswCandidate *hcb = lfirst(b);
|
||||||
#else
|
#else
|
||||||
CompareCandidateDistancesOffset(const void *a, const void *b)
|
CompareCandidateDistancesOffset(const void *a, const void *b)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
HnswCandidate *hca = lfirst((ListCell *) a);
|
HnswCandidate *hca = lfirst(*(ListCell **) a);
|
||||||
HnswCandidate *hcb = lfirst((ListCell *) b);
|
HnswCandidate *hcb = lfirst(*(ListCell **) b);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (hca->distance < hcb->distance)
|
if (hca->distance < hcb->distance)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user