Compare commits

..

1 Commits

Author SHA1 Message Date
Andrew Kane
a6420355c5 Updated FreeBSD package name in readme [skip ci] 2026-07-10 22:17:27 -07:00
2 changed files with 5 additions and 34 deletions

View File

@@ -1233,7 +1233,7 @@ Note: Replace `18` with your Postgres server version
Install the FreeBSD package with: Install the FreeBSD package with:
```sh ```sh
pkg install postgresql17-pgvector pkg install postgresql18-pgvector
``` ```
or the port with: or the port with:

View File

@@ -8,7 +8,6 @@
#include "fmgr.h" #include "fmgr.h"
#include "ivfflat.h" #include "ivfflat.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "utils/datum.h"
#include "utils/memutils.h" #include "utils/memutils.h"
#include "utils/relcache.h" #include "utils/relcache.h"
@@ -106,44 +105,16 @@ NormCenters(const IvfflatTypeInfo * typeInfo, Oid collation, VectorArray centers
} }
/* /*
* Check if vector array contains a vector * Quick approach if we have no data
*/
static bool
VectorArrayContains(VectorArray arr, Pointer val)
{
Datum d = PointerGetDatum(val);
for (int i = 0; i < arr->length; i++)
{
if (datumIsEqual(d, PointerGetDatum(VectorArrayGet(arr, i)), false, -1))
return true;
}
return false;
}
/*
* Quick approach if we have little data
*/ */
static void static void
QuickCenters(Relation index, VectorArray samples, VectorArray centers, const IvfflatTypeInfo * typeInfo) RandomCenters(Relation index, VectorArray centers, const IvfflatTypeInfo * typeInfo)
{ {
int dimensions = centers->dim; int dimensions = centers->dim;
FmgrInfo *normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC); FmgrInfo *normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC);
Oid collation = index->rd_indcollation[0]; Oid collation = index->rd_indcollation[0];
float *x = (float *) palloc(sizeof(float) * dimensions); float *x = (float *) palloc(sizeof(float) * dimensions);
/* Fill with unique samples (already normalized) */
for (int i = 0; i < samples->length; i++)
{
Pointer sample = VectorArrayGet(samples, i);
if (!VectorArrayContains(centers, sample))
{
VectorArraySet(centers, centers->length, sample);
centers->length++;
}
}
/* Fill with random data */ /* Fill with random data */
while (centers->length < centers->maxlen) while (centers->length < centers->maxlen)
{ {
@@ -577,8 +548,8 @@ IvfflatKmeans(Relation index, VectorArray samples, VectorArray centers, const Iv
ALLOCSET_DEFAULT_SIZES); ALLOCSET_DEFAULT_SIZES);
MemoryContext oldCtx = MemoryContextSwitchTo(kmeansCtx); MemoryContext oldCtx = MemoryContextSwitchTo(kmeansCtx);
if (samples->length <= centers->maxlen) if (samples->length == 0)
QuickCenters(index, samples, centers, typeInfo); RandomCenters(index, centers, typeInfo);
else else
ElkanKmeans(index, samples, centers, typeInfo, memoryUsed); ElkanKmeans(index, samples, centers, typeInfo, memoryUsed);