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