in java/src/main/java/com/spotify/voyager/jni/StringIndex.java [341:362]
private QueryResults convertResult(Index.QueryResults idxResults) {
int numResults = idxResults.distances.length;
String[] resultNames = new String[numResults];
float[] distances = new float[numResults];
for (int i = 0; i < idxResults.getLabels().length; i++) {
long indexId = idxResults.getLabels()[i];
float dist = idxResults.getDistances()[i];
if (indexId > Integer.MAX_VALUE || indexId < Integer.MIN_VALUE) {
throw new ArrayIndexOutOfBoundsException(
"Voyager index returned a label ("
+ indexId
+ ") which is out of range for StringIndex. "
+ "This index may not be compatible with Voyager's Java bindings, or the index file may be corrupt.");
}
String name = names.get((int) indexId);
resultNames[i] = name;
distances[i] = dist;
}
return new QueryResults(resultNames, distances);
}