int itemIDIndex = itemIDIndexWritable.get();
TopSimilarItemsQueue topKMostSimilarItems = new TopSimilarItemsQueue(maxSimilarItemsPerItem);
for (Vector.Element element : similarityVector.get().nonZeroes()) {
SimilarItem top = topKMostSimilarItems.top();
double candidateSimilarity = element.get();
if (candidateSimilarity > top.getSimilarity()) {
top.set(indexItemIDMap.get(element.index()), candidateSimilarity);
topKMostSimilarItems.updateTop();
}
}
long itemID = indexItemIDMap.get(itemIDIndex);