Skip to content

Commit b6d61fa

Browse files
committed
removed sorting on writeCentroids
1 parent 4cd94cf commit b6d61fa

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/DefaultIVFVectorsWriter.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,25 +213,7 @@ static void writeCentroids(float[][] centroids, FieldInfo fieldInfo, float[] glo
213213
byte[] quantizedScratch = new byte[fieldInfo.getVectorDimension()];
214214
float[] centroidScratch = new float[fieldInfo.getVectorDimension()];
215215
// TODO do we want to store these distances as well for future use?
216-
// TODO: this sorting operation tanks recall for some reason, works fine for small numbers of vectors like in single segment
217-
// need to investigate this further
218-
float[] distances = new float[centroids.length];
219-
for (int i = 0; i < centroids.length; i++) {
220-
distances[i] = VectorUtil.squareDistance(centroids[i], globalCentroid);
221-
}
222-
// sort the centroids by distance to globalCentroid, nearest (smallest distance), to furthest (largest)
223-
for (int i = 0; i < centroids.length; i++) {
224-
for (int j = i + 1; j < centroids.length; j++) {
225-
if (distances[i] > distances[j]) {
226-
float[] tmp = centroids[i];
227-
centroids[i] = centroids[j];
228-
centroids[j] = tmp;
229-
float tmpDistance = distances[i];
230-
distances[i] = distances[j];
231-
distances[j] = tmpDistance;
232-
}
233-
}
234-
}
216+
// TODO: sorting tanks recall possibly because centroids ordinals no longer are aligned; do sorting prior to this w assignments?
235217
for (float[] centroid : centroids) {
236218
System.arraycopy(centroid, 0, centroidScratch, 0, centroid.length);
237219
OptimizedScalarQuantizer.QuantizationResult result = osq.scalarQuantize(

0 commit comments

Comments
 (0)