From 2ae4de83fe81f7fd6164c585838bd8a0a40570d2 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 30 Jan 2022 11:57:52 -0800 Subject: [PATCH] Improved error message for spherical k-means with one dimension --- src/ivfbuild.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index e67a4b2..c9264e8 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -318,6 +318,12 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In buildstate->kmeansnormprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC); buildstate->collation = index->rd_indcollation[0]; + /* Require more than one dimension for spherical k-means */ + /* Lists check for backwards compatibility */ + /* TODO Remove lists check in 0.3.0 */ + if (buildstate->kmeansnormprocinfo != NULL && buildstate->dimensions == 1 && buildstate->lists > 1) + elog(ERROR, "dimensions must be greater than one for this opclass"); + /* Create tuple description for sorting */ #if PG_VERSION_NUM >= 120000 buildstate->tupdesc = CreateTemplateTupleDesc(4);