From 3e924ab7ad4341cd247d1c9a699e1e8e3b96fcaa Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 24 Apr 2024 18:04:26 -0700 Subject: [PATCH] Added checkDuplicates to KmeansState [skip ci] --- src/ivfkmeans.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 4713929..774f530 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -20,6 +20,7 @@ typedef struct KmeansState void (*sumCenter) (Pointer v, float *x); int (*comp) (const void *a, const void *b); bool separateAgg; + bool checkDuplicates; } KmeansState; /* @@ -724,7 +725,7 @@ CheckCenters(Relation index, VectorArray centers, IvfflatType type, KmeansState elog(ERROR, "Unsupported type"); } - if (type != IVFFLAT_TYPE_BIT) + if (kmeansstate->checkDuplicates) { /* Ensure no duplicate centers */ SortVectorArray(centers, kmeansstate); @@ -763,6 +764,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type) kmeansstate->sumCenter = VectorSumCenter; kmeansstate->comp = CompareVectors; kmeansstate->separateAgg = false; + kmeansstate->checkDuplicates = true; } else if (type == IVFFLAT_TYPE_HALFVEC) { @@ -771,6 +773,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type) kmeansstate->sumCenter = HalfvecSumCenter; kmeansstate->comp = CompareHalfVectors; kmeansstate->separateAgg = true; + kmeansstate->checkDuplicates = true; } else if (type == IVFFLAT_TYPE_BIT) { @@ -779,6 +782,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type) kmeansstate->sumCenter = BitSumCenter; kmeansstate->comp = CompareBitVectors; kmeansstate->separateAgg = true; + kmeansstate->checkDuplicates = false; } else elog(ERROR, "Unsupported type");