Skip to content

Commit cf3e558

Browse files
committed
Remove forbidden API
1 parent 96d2987 commit cf3e558

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lucene/core/src/test/org/apache/lucene/search/TestTwoPhaseKnnVectorQuery.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.apache.lucene.search;
218

319
import java.util.HashMap;
@@ -18,11 +34,12 @@
1834
import org.apache.lucene.index.VectorSimilarityFunction;
1935
import org.apache.lucene.store.ByteBuffersDirectory;
2036
import org.apache.lucene.store.Directory;
37+
import org.apache.lucene.tests.util.LuceneTestCase;
2138
import org.junit.Assert;
2239
import org.junit.Before;
2340
import org.junit.Test;
2441

25-
public class TestTwoPhaseKnnVectorQuery {
42+
public class TestTwoPhaseKnnVectorQuery extends LuceneTestCase {
2643

2744
private static final String FIELD = "vector";
2845
public static final VectorSimilarityFunction VECTOR_SIMILARITY_FUNCTION =
@@ -34,6 +51,7 @@ public class TestTwoPhaseKnnVectorQuery {
3451

3552
@Before
3653
public void setUp() throws Exception {
54+
super.setUp();
3755
directory = new ByteBuffersDirectory();
3856

3957
// Set up the IndexWriterConfig to use quantized vector storage
@@ -45,9 +63,10 @@ public void setUp() throws Exception {
4563
public void testTwoPhaseKnnVectorQuery() throws Exception {
4664
Map<Integer, float[]> vectors = new HashMap<>();
4765

66+
Random random = random();
67+
4868
// Step 1: Index random vectors in quantized format
4969
try (IndexWriter writer = new IndexWriter(directory, config)) {
50-
Random random = new Random();
5170
for (int i = 0; i < NUM_VECTORS; i++) {
5271
float[] vector = randomFloatVector(VECTOR_DIMENSION, random);
5372
Document doc = new Document();
@@ -61,7 +80,7 @@ public void testTwoPhaseKnnVectorQuery() throws Exception {
6180
// Step 2: Run TwoPhaseKnnVectorQuery with a random target vector
6281
try (IndexReader reader = DirectoryReader.open(directory)) {
6382
IndexSearcher searcher = new IndexSearcher(reader);
64-
float[] targetVector = randomFloatVector(VECTOR_DIMENSION, new Random());
83+
float[] targetVector = randomFloatVector(VECTOR_DIMENSION, random);
6584
int k = 10;
6685
double oversample = 1.0;
6786

0 commit comments

Comments
 (0)