Skip to content

Commit 5970f7b

Browse files
committed
adding java docs
1 parent 6f85cd9 commit 5970f7b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

server/src/main/java/org/elasticsearch/search/vectors/AbstractMaxScoreKnnCollector.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,32 @@
1313
import org.apache.lucene.search.knn.KnnSearchStrategy;
1414
import org.elasticsearch.index.codec.vectors.cluster.NeighborQueue;
1515

16-
public abstract class AbstractMaxScoreKnnCollector extends AbstractKnnCollector {
16+
/**
17+
* Abstract class for collectors that maintain a maximum score for KNN search.
18+
* It extends the {@link AbstractKnnCollector} and provides methods to manage
19+
* the minimum competitive document score, useful for tracking competitive scores
20+
* over multiple leaves.
21+
*/
22+
abstract class AbstractMaxScoreKnnCollector extends AbstractKnnCollector {
1723
public static final long LEAST_COMPETITIVE = NeighborQueue.encodeRaw(Integer.MAX_VALUE, Float.NEGATIVE_INFINITY);
1824

1925
protected AbstractMaxScoreKnnCollector(int k, long visitLimit, KnnSearchStrategy searchStrategy) {
2026
super(k, visitLimit, searchStrategy);
2127
}
2228

29+
/**
30+
* Returns the minimum competitive document score.
31+
* This is used to determine the global competitiveness of documents in the search.
32+
* This may be a competitive score even if the collector hasn't collected k results yet.
33+
*
34+
* @return the minimum competitive document score
35+
*/
2336
public abstract long getMinCompetitiveDocScore();
2437

38+
/**
39+
* Updates the minimum competitive document score.
40+
*
41+
* @param minCompetitiveDocScore the new minimum competitive document score to set
42+
*/
2543
abstract void updateMinCompetitiveDocScore(long minCompetitiveDocScore);
2644
}

server/src/main/java/org/elasticsearch/search/vectors/IVFKnnSearchStrategy.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public int hashCode() {
4848
return Objects.hashCode(visitRatio);
4949
}
5050

51+
/**
52+
* This method is called when the next block of vectors is processed.
53+
* It accumulates the minimum competitive document score from the collector
54+
* and updates the accumulator with the most competitive score.
55+
* If the current score in the accumulator is greater than the minimum competitive
56+
* document score in the collector, it updates the collector's minimum competitive document score.
57+
*/
5158
@Override
5259
public void nextVectorsBlock() {
5360
if (accumulator == null) {

0 commit comments

Comments
 (0)