From 991743786a754218172ea5d2ebb8817df3c74ea0 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 23 Apr 2024 15:47:04 -0700 Subject: [PATCH] Set length for newCenters and aggCenters [skip ci] --- src/ivfkmeans.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index 71d99a6..774c98e 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -99,7 +99,7 @@ NormCenters(FmgrInfo *normalizeprocinfo, Oid collation, VectorArray centers) ALLOCSET_DEFAULT_SIZES); MemoryContext oldCtx = MemoryContextSwitchTo(normCtx); - for (int j = 0; j < centers->maxlen; j++) + for (int j = 0; j < centers->length; j++) { Datum center = PointerGetDatum(VectorArrayGet(centers, j)); Datum newCenter = IvfflatNormValue(normalizeprocinfo, collation, center); @@ -483,6 +483,9 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers, IvfflatTyp else elog(ERROR, "Unsupported type"); + aggCenters->length = aggCenters->maxlen; + newCenters->length = newCenters->maxlen; + #ifdef IVFFLAT_MEMORY ShowMemoryUsage(oldCtx, totalSize); #endif