From b8f3688e4129b5bc5b9f1c4232e4c6a441d24953 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 6 May 2021 22:31:17 -0700 Subject: [PATCH] Fixed kmeans for inner product --- CHANGELOG.md | 1 + src/ivfbuild.c | 6 ++++-- src/ivfflat.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7d288f..ea98bab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 0.1.4 (unreleased) +- Fixed kmeans for inner product - Fixed multiple definition error with GCC 10 ## 0.1.3 (2021-05-06) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 228db3c..2788b45 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -42,9 +42,10 @@ SampleCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values, return; /* Normalize the value */ - if (buildstate->normprocinfo != NULL) + /* Use KMEANS_NORM_PROC for spherical distance function */ + if (buildstate->kmeansnormprocinfo != NULL) { - if (!IvfflatNormValue(buildstate->normprocinfo, buildstate->collation, &value, buildstate->normvec)) + if (!IvfflatNormValue(buildstate->kmeansnormprocinfo, buildstate->collation, &value, buildstate->normvec)) return; } @@ -275,6 +276,7 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In /* Get support functions */ buildstate->procinfo = index_getprocinfo(index, 1, IVFFLAT_DISTANCE_PROC); buildstate->normprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_NORM_PROC); + buildstate->kmeansnormprocinfo = IvfflatOptionalProcInfo(index, IVFFLAT_KMEANS_NORM_PROC); buildstate->collation = index->rd_indcollation[0]; /* Create tuple description for sorting */ diff --git a/src/ivfflat.h b/src/ivfflat.h index 1adab84..44d6583 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -81,6 +81,7 @@ typedef struct IvfflatBuildState /* Support functions */ FmgrInfo *procinfo; FmgrInfo *normprocinfo; + FmgrInfo *kmeansnormprocinfo; Oid collation; /* Variables */