From 4209c9b3af60c5564737993269a4a90459305e8f Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 12 Sep 2023 16:13:10 -0700 Subject: [PATCH] Improved variable scoping --- src/ivfkmeans.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index d0fd1ce..c2eb59a 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -17,10 +17,6 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low FmgrInfo *procinfo; Oid collation; int64 j; - double distance; - double sum; - double choice; - Vector *vec; float *weight = palloc(samples->length * sizeof(float)); int numCenters = centers->maxlen; int numSamples = samples->length; @@ -37,13 +33,17 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low for (int i = 0; i < numCenters; i++) { + double sum; + double choice; + CHECK_FOR_INTERRUPTS(); sum = 0.0; for (j = 0; j < numSamples; j++) { - vec = VectorArrayGet(samples, j); + Vector *vec = VectorArrayGet(samples, j); + double distance; /* Only need to compute distance for new center */ /* TODO Use triangle inequality to reduce distance calculations */