pgvector.git / summary / log / commit / refs
commit 75e09265d6b3b4db2d06b42ce96387258c1fed23
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Sep 13 01:14:20 2023 +0000
Improved variable scoping [skip ci]
src/ivfkmeans.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c
index 1def70e7..cd72736c 100644
--- a/src/ivfkmeans.c
+++ b/src/ivfkmeans.c
@@ -464,9 +464,6 @@ static void
CheckCenters(Relation index, VectorArray centers)
{
FmgrInfo *normprocinfo;
- Oid collation;
- Vector *vec;
- double norm;
if (centers->length != centers->maxlen)
elog(ERROR, "Not enough centers. Please report a bug.");
@@ -474,7 +471,7 @@ CheckCenters(Relation index, VectorArray centers)
/* Ensure no NaN or infinite values */
for (int i = 0; i < centers->length; i++)
{
- vec = VectorArrayGet(centers, i);
+ Vector *vec = VectorArrayGet(centers, i);
for (int j = 0; j < vec->dim; j++)
{
@@ -500,11 +497,12 @@ CheckCenters(Relation index, VectorArray centers)
normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_NORM_PROC);
if (normprocinfo != NULL)
{
- collation = index->rd_indcollation[0];
+ Oid collation = index->rd_indcollation[0];
for (int i = 0; i < centers->length; i++)
{
- norm = DatumGetFloat8(FunctionCall1Coll(normprocinfo, collation, PointerGetDatum(VectorArrayGet(centers, i))));
+ double norm = DatumGetFloat8(FunctionCall1Coll(normprocinfo, collation, PointerGetDatum(VectorArrayGet(centers, i))));
+
if (norm == 0)
elog(ERROR, "Zero norm detected. Please report a bug.");
}
[parent: 77c5070fb6ff]