3838import java .util .AbstractList ;
3939import java .util .Arrays ;
4040
41+ import static org .elasticsearch .index .codec .vectors .cluster .HierarchicalKMeans .NO_SOAR_ASSIGNMENT ;
42+
4143/**
4244 * Default implementation of {@link IVFVectorsWriter}. It uses {@link HierarchicalKMeans} algorithm to
4345 * partition the vector space, and then stores the centroids and posting list in a sequential
@@ -75,7 +77,7 @@ CentroidOffsetAndLength buildAndWritePostingsLists(
7577 for (int i = 0 ; i < assignments .length ; i ++) {
7678 centroidVectorCount [assignments [i ]]++;
7779 // if soar assignments are present, count them as well
78- if (overspillAssignments .length > i && overspillAssignments [i ] != - 1 ) {
80+ if (overspillAssignments .length > i && overspillAssignments [i ] != NO_SOAR_ASSIGNMENT ) {
7981 centroidVectorCount [overspillAssignments [i ]]++;
8082 }
8183 }
@@ -95,7 +97,7 @@ CentroidOffsetAndLength buildAndWritePostingsLists(
9597 // if soar assignments are present, add them to the cluster as well
9698 if (overspillAssignments .length > i ) {
9799 int s = overspillAssignments [i ];
98- if (s != - 1 ) {
100+ if (s != NO_SOAR_ASSIGNMENT ) {
99101 assignmentsByCluster [s ][centroidVectorCount [s ]++] = i ;
100102 }
101103 }
@@ -187,7 +189,7 @@ CentroidOffsetAndLength buildAndWritePostingsLists(
187189 int c = assignments [i ];
188190 float [] centroid = centroidSupplier .centroid (c );
189191 float [] vector = floatVectorValues .vectorValue (i );
190- boolean overspill = overspillAssignments .length > i && overspillAssignments [i ] != - 1 ;
192+ boolean overspill = overspillAssignments .length > i && overspillAssignments [i ] != NO_SOAR_ASSIGNMENT ;
191193 OptimizedScalarQuantizer .QuantizationResult result = quantizer .scalarQuantize (
192194 vector ,
193195 scratch ,
@@ -220,7 +222,7 @@ CentroidOffsetAndLength buildAndWritePostingsLists(
220222 for (int i = 0 ; i < assignments .length ; i ++) {
221223 centroidVectorCount [assignments [i ]]++;
222224 // if soar assignments are present, count them as well
223- if (overspillAssignments .length > i && overspillAssignments [i ] != - 1 ) {
225+ if (overspillAssignments .length > i && overspillAssignments [i ] != NO_SOAR_ASSIGNMENT ) {
224226 centroidVectorCount [overspillAssignments [i ]]++;
225227 }
226228 }
@@ -242,7 +244,7 @@ CentroidOffsetAndLength buildAndWritePostingsLists(
242244 // if soar assignments are present, add them to the cluster as well
243245 if (overspillAssignments .length > i ) {
244246 int s = overspillAssignments [i ];
245- if (s != - 1 ) {
247+ if (s != NO_SOAR_ASSIGNMENT ) {
246248 assignmentsByCluster [s ][centroidVectorCount [s ]] = i ;
247249 isOverspillByCluster [s ][centroidVectorCount [s ]++] = true ;
248250 }
0 commit comments