Skip to content

Commit 1a73b56

Browse files
authored
Fix usage of null acceptOrds in SiftSmall example (#152)
Since #117, acceptOrds should not be null. Instead, Bits.ALL should be used. Also updated GraphSearcher#search javadoc to match implementation.
1 parent 06fa067 commit 1a73b56

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

jvector-base/src/main/java/io/github/jbellis/jvector/graph/GraphSearcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public GraphSearcher<T> build() {
115115
* @param topK the number of results to look for
116116
* @param threshold the minimum similarity (0..1) to accept; 0 will accept everything. (Experimental!)
117117
* @param acceptOrds a Bits instance indicating which nodes are acceptable results.
118-
* If null, all nodes are acceptable.
118+
* If {@link Bits#ALL}, all nodes are acceptable.
119119
* It is caller's responsibility to ensure that there are enough acceptable nodes
120120
* that we don't search the entire graph trying to satisfy topK.
121121
* @return a SearchResult containing the topK results and the number of nodes visited during the search.
@@ -135,7 +135,7 @@ public SearchResult search(NodeSimilarity.ScoreFunction scoreFunction,
135135
* comparisons of the vectors for re-ranking at the end of the search.
136136
* @param topK the number of results to look for
137137
* @param acceptOrds a Bits instance indicating which nodes are acceptable results.
138-
* If null, all nodes are acceptable.
138+
* If {@link Bits#ALL}, all nodes are acceptable.
139139
* It is caller's responsibility to ensure that there are enough acceptable nodes
140140
* that we don't search the entire graph trying to satisfy topK.
141141
* @return a SearchResult containing the topK results and the number of nodes visited during the search.

jvector-examples/src/main/java/io/github/jbellis/jvector/example/SiftSmall.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import io.github.jbellis.jvector.pq.CompressedVectors;
2525
import io.github.jbellis.jvector.pq.PQVectors;
2626
import io.github.jbellis.jvector.pq.ProductQuantization;
27+
import io.github.jbellis.jvector.util.Bits;
2728
import io.github.jbellis.jvector.vector.VectorEncoding;
2829
import io.github.jbellis.jvector.vector.VectorSimilarityFunction;
2930

@@ -86,12 +87,12 @@ private static void testRecallInternal(GraphIndex<float[]> graph, RandomAccessVe
8687
var searcher = new GraphSearcher.Builder<>(view).build();
8788
if (compressedVectors == null) {
8889
NodeSimilarity.ExactScoreFunction sf = (j) -> VectorSimilarityFunction.EUCLIDEAN.compare(queryVector, ravv.vectorValue(j));
89-
nn = searcher.search(sf, null, 100, null).getNodes();
90+
nn = searcher.search(sf, null, 100, Bits.ALL).getNodes();
9091
}
9192
else {
9293
NodeSimilarity.ApproximateScoreFunction sf = compressedVectors.approximateScoreFunctionFor(queryVector, VectorSimilarityFunction.EUCLIDEAN);
9394
NodeSimilarity.ReRanker<float[]> rr = (j, vectors) -> VectorSimilarityFunction.EUCLIDEAN.compare(queryVector, vectors.get(j));
94-
nn = searcher.search(sf, rr, 100, null).getNodes();
95+
nn = searcher.search(sf, rr, 100, Bits.ALL).getNodes();
9596
}
9697

9798
var gt = groundTruth.get(i);

0 commit comments

Comments
 (0)