From 12f158d4bbb392a52438ae9a14cf8fc2602c0379 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 2 Nov 2022 12:27:09 -0700 Subject: [PATCH] Fixed warning --- src/ivfkmeans.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c index bef0880..e814f54 100644 --- a/src/ivfkmeans.c +++ b/src/ivfkmeans.c @@ -204,10 +204,6 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) double dxcx; double dxc; - /* Ensure indexing does not overflow */ - if (numCenters * numCenters > INT_MAX) - elog(ERROR, "Indexing overflow detected. Please report a bug."); - /* Calculate allocation sizes */ Size samplesSize = VECTOR_ARRAY_SIZE(samples->maxlen, samples->dim); Size centersSize = VECTOR_ARRAY_SIZE(centers->maxlen, centers->dim); @@ -231,6 +227,10 @@ ElkanKmeans(Relation index, VectorArray samples, VectorArray centers) errmsg("memory required is %zu MB, maintenance_work_mem is %d MB", totalSize / (1024 * 1024) + 1, maintenance_work_mem / 1024))); + /* Ensure indexing does not overflow */ + if (numCenters * numCenters > INT_MAX) + elog(ERROR, "Indexing overflow detected. Please report a bug."); + /* Set support functions */ procinfo = index_getprocinfo(index, 1, IVFFLAT_KMEANS_DISTANCE_PROC); normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC);