mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 00:26:55 +08:00
Improved code [skip ci]
This commit is contained in:
@@ -121,6 +121,8 @@ QuickCenters(Relation index, VectorArray samples, VectorArray centers)
|
|||||||
FmgrInfo *normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC);
|
FmgrInfo *normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC);
|
||||||
|
|
||||||
/* Copy existing vectors while avoiding duplicates */
|
/* Copy existing vectors while avoiding duplicates */
|
||||||
|
if (samples->length > 0)
|
||||||
|
{
|
||||||
qsort(samples->items, samples->length, VECTOR_SIZE(samples->dim), CompareVectors);
|
qsort(samples->items, samples->length, VECTOR_SIZE(samples->dim), CompareVectors);
|
||||||
for (i = 0; i < samples->length; i++)
|
for (i = 0; i < samples->length; i++)
|
||||||
{
|
{
|
||||||
@@ -132,6 +134,7 @@ QuickCenters(Relation index, VectorArray samples, VectorArray centers)
|
|||||||
centers->length++;
|
centers->length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Fill remaining with random data */
|
/* Fill remaining with random data */
|
||||||
while (centers->length < centers->maxlen)
|
while (centers->length < centers->maxlen)
|
||||||
|
|||||||
Reference in New Issue
Block a user