@@ -60,8 +60,10 @@ AddSample(Datum *values, IvfflatBuildState * buildstate)
6060 */
6161 if (buildstate -> kmeansnormprocinfo != NULL )
6262 {
63- if (!IvfflatNormValue (buildstate -> kmeansnormprocinfo , buildstate -> collation , & value , buildstate -> type ))
63+ if (!IvfflatCheckNorm (buildstate -> kmeansnormprocinfo , buildstate -> collation , value ))
6464 return ;
65+
66+ value = IvfflatNormValue (buildstate -> normalizeprocinfo , buildstate -> collation , value );
6567 }
6668
6769 if (samples -> length < targsamples )
@@ -156,8 +158,10 @@ AddTupleToSort(Relation index, ItemPointer tid, Datum *values, IvfflatBuildState
156158 /* Normalize if needed */
157159 if (buildstate -> normprocinfo != NULL )
158160 {
159- if (!IvfflatNormValue (buildstate -> normprocinfo , buildstate -> collation , & value , buildstate -> type ))
161+ if (!IvfflatCheckNorm (buildstate -> normprocinfo , buildstate -> collation , value ))
160162 return ;
163+
164+ value = IvfflatNormValue (buildstate -> normalizeprocinfo , buildstate -> collation , value );
161165 }
162166
163167 /* Find the list that minimizes the distance */
@@ -379,6 +383,7 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In
379383 buildstate -> procinfo = index_getprocinfo (index , 1 , IVFFLAT_DISTANCE_PROC );
380384 buildstate -> normprocinfo = IvfflatOptionalProcInfo (index , IVFFLAT_NORM_PROC );
381385 buildstate -> kmeansnormprocinfo = IvfflatOptionalProcInfo (index , IVFFLAT_KMEANS_NORM_PROC );
386+ buildstate -> normalizeprocinfo = IvfflatOptionalProcInfo (index , IVFFLAT_NORMALIZE_PROC );
382387 buildstate -> collation = index -> rd_indcollation [0 ];
383388
384389 /* Require more than one dimension for spherical k-means */
0 commit comments