mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-13 16:16:56 +08:00
Improved SortVectorArray [skip ci]
This commit is contained in:
@@ -149,14 +149,18 @@ CompareBitVectors(const void *a, const void *b)
|
|||||||
static void
|
static void
|
||||||
SortVectorArray(VectorArray arr, IvfflatType type)
|
SortVectorArray(VectorArray arr, IvfflatType type)
|
||||||
{
|
{
|
||||||
|
int (*comp) (const void *a, const void *b);
|
||||||
|
|
||||||
if (type == IVFFLAT_TYPE_VECTOR)
|
if (type == IVFFLAT_TYPE_VECTOR)
|
||||||
qsort(arr->items, arr->length, arr->itemsize, CompareVectors);
|
comp = CompareVectors;
|
||||||
else if (type == IVFFLAT_TYPE_HALFVEC)
|
else if (type == IVFFLAT_TYPE_HALFVEC)
|
||||||
qsort(arr->items, arr->length, arr->itemsize, CompareHalfVectors);
|
comp = CompareHalfVectors;
|
||||||
else if (type == IVFFLAT_TYPE_BIT)
|
else if (type == IVFFLAT_TYPE_BIT)
|
||||||
qsort(arr->items, arr->length, arr->itemsize, CompareBitVectors);
|
comp = CompareBitVectors;
|
||||||
else
|
else
|
||||||
elog(ERROR, "Unsupported type");
|
elog(ERROR, "Unsupported type");
|
||||||
|
|
||||||
|
qsort(arr->items, arr->length, arr->itemsize, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user