Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ public void setup() throws IOException {
for (int i = 0; i < dims; i++) {
queryVec[i] = ThreadLocalRandom.current().nextFloat();
}
luceneDotScorerQuery = luceneScorer(values, VectorSimilarityFunction.DOT_PRODUCT, queryVec);
nativeDotScorerQuery = factory.getInt7SQVectorScorer(VectorSimilarityFunction.DOT_PRODUCT, values, queryVec).get();
luceneSqrScorerQuery = luceneScorer(values, VectorSimilarityFunction.EUCLIDEAN, queryVec);
nativeSqrScorerQuery = factory.getInt7SQVectorScorer(VectorSimilarityFunction.EUCLIDEAN, values, queryVec).get();

if (Runtime.version().feature() >= 22) {
luceneDotScorerQuery = luceneScorer(values, VectorSimilarityFunction.DOT_PRODUCT, queryVec);
nativeDotScorerQuery = factory.getInt7SQVectorScorer(VectorSimilarityFunction.DOT_PRODUCT, values, queryVec).get();
luceneSqrScorerQuery = luceneScorer(values, VectorSimilarityFunction.EUCLIDEAN, queryVec);
nativeSqrScorerQuery = factory.getInt7SQVectorScorer(VectorSimilarityFunction.EUCLIDEAN, values, queryVec).get();
}
}

@TearDown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public static void skipWindows() {
assumeFalse("doesn't work on windows yet", Constants.WINDOWS);
}

static boolean supportsHeapSegments() {
return Runtime.version().feature() >= 22;
}

public void testDotProduct() throws Exception {
for (int i = 0; i < 100; i++) {
var bench = new Int7uScorerBenchmark();
Expand All @@ -42,8 +46,10 @@ public void testDotProduct() throws Exception {
assertEquals(expected, bench.dotProductLucene(), delta);
assertEquals(expected, bench.dotProductNative(), delta);

expected = bench.dotProductLuceneQuery();
assertEquals(expected, bench.dotProductNativeQuery(), delta);
if (supportsHeapSegments()) {
expected = bench.dotProductLuceneQuery();
assertEquals(expected, bench.dotProductNativeQuery(), delta);
}
} finally {
bench.teardown();
}
Expand All @@ -60,8 +66,10 @@ public void testSquareDistance() throws Exception {
assertEquals(expected, bench.squareDistanceLucene(), delta);
assertEquals(expected, bench.squareDistanceNative(), delta);

expected = bench.squareDistanceLuceneQuery();
assertEquals(expected, bench.squareDistanceNativeQuery(), delta);
if (supportsHeapSegments()) {
expected = bench.squareDistanceLuceneQuery();
assertEquals(expected, bench.squareDistanceNativeQuery(), delta);
}
} finally {
bench.teardown();
}
Expand Down