mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 23:56:55 +08:00
Added checkDuplicates to KmeansState [skip ci]
This commit is contained in:
@@ -20,6 +20,7 @@ typedef struct KmeansState
|
|||||||
void (*sumCenter) (Pointer v, float *x);
|
void (*sumCenter) (Pointer v, float *x);
|
||||||
int (*comp) (const void *a, const void *b);
|
int (*comp) (const void *a, const void *b);
|
||||||
bool separateAgg;
|
bool separateAgg;
|
||||||
|
bool checkDuplicates;
|
||||||
} KmeansState;
|
} KmeansState;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -724,7 +725,7 @@ CheckCenters(Relation index, VectorArray centers, IvfflatType type, KmeansState
|
|||||||
elog(ERROR, "Unsupported type");
|
elog(ERROR, "Unsupported type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != IVFFLAT_TYPE_BIT)
|
if (kmeansstate->checkDuplicates)
|
||||||
{
|
{
|
||||||
/* Ensure no duplicate centers */
|
/* Ensure no duplicate centers */
|
||||||
SortVectorArray(centers, kmeansstate);
|
SortVectorArray(centers, kmeansstate);
|
||||||
@@ -763,6 +764,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type)
|
|||||||
kmeansstate->sumCenter = VectorSumCenter;
|
kmeansstate->sumCenter = VectorSumCenter;
|
||||||
kmeansstate->comp = CompareVectors;
|
kmeansstate->comp = CompareVectors;
|
||||||
kmeansstate->separateAgg = false;
|
kmeansstate->separateAgg = false;
|
||||||
|
kmeansstate->checkDuplicates = true;
|
||||||
}
|
}
|
||||||
else if (type == IVFFLAT_TYPE_HALFVEC)
|
else if (type == IVFFLAT_TYPE_HALFVEC)
|
||||||
{
|
{
|
||||||
@@ -771,6 +773,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type)
|
|||||||
kmeansstate->sumCenter = HalfvecSumCenter;
|
kmeansstate->sumCenter = HalfvecSumCenter;
|
||||||
kmeansstate->comp = CompareHalfVectors;
|
kmeansstate->comp = CompareHalfVectors;
|
||||||
kmeansstate->separateAgg = true;
|
kmeansstate->separateAgg = true;
|
||||||
|
kmeansstate->checkDuplicates = true;
|
||||||
}
|
}
|
||||||
else if (type == IVFFLAT_TYPE_BIT)
|
else if (type == IVFFLAT_TYPE_BIT)
|
||||||
{
|
{
|
||||||
@@ -779,6 +782,7 @@ InitKmeansState(KmeansState * kmeansstate, IvfflatType type)
|
|||||||
kmeansstate->sumCenter = BitSumCenter;
|
kmeansstate->sumCenter = BitSumCenter;
|
||||||
kmeansstate->comp = CompareBitVectors;
|
kmeansstate->comp = CompareBitVectors;
|
||||||
kmeansstate->separateAgg = true;
|
kmeansstate->separateAgg = true;
|
||||||
|
kmeansstate->checkDuplicates = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
elog(ERROR, "Unsupported type");
|
elog(ERROR, "Unsupported type");
|
||||||
|
|||||||
Reference in New Issue
Block a user