Skip to content

Commit 1770c2f

Browse files
committed
tidy
1 parent 5edbd2b commit 1770c2f

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

lucene/core/src/java/org/apache/lucene/search/ByteVectorSimilarityValuesSource.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
*/
3434
class ByteVectorSimilarityValuesSource extends VectorSimilarityValuesSource {
3535

36-
/** Creates a {@link ByteVectorSimilarityValuesSource} that scores on full precision vector values */
36+
/**
37+
* Creates a {@link ByteVectorSimilarityValuesSource} that scores on full precision vector values
38+
*/
3739
public static DoubleValues fullPrecisionScores(
3840
LeafReaderContext ctx, byte[] queryVector, String vectorField) throws IOException {
39-
return new ByteVectorSimilarityValuesSource(queryVector, vectorField, true).getValues(ctx, null);
41+
return new ByteVectorSimilarityValuesSource(queryVector, vectorField, true)
42+
.getValues(ctx, null);
4043
}
4144

4245
private final byte[] queryVector;
@@ -62,7 +65,8 @@ public ByteVectorSimilarityValuesSource(byte[] vector, String fieldName) {
6265
* @param useFullPrecision uses full precision raw vectors for similarity computation if true,
6366
* otherwise the configured vectors reader is used, which may be quantized or full precision.
6467
*/
65-
public ByteVectorSimilarityValuesSource(byte[] vector, String fieldName, boolean useFullPrecision) {
68+
public ByteVectorSimilarityValuesSource(
69+
byte[] vector, String fieldName, boolean useFullPrecision) {
6670
super(fieldName);
6771
this.queryVector = vector;
6872
this.useFullPrecision = useFullPrecision;

lucene/core/src/java/org/apache/lucene/search/DoubleValuesSource.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.lucene.index.DocValues;
2525
import org.apache.lucene.index.LeafReaderContext;
2626
import org.apache.lucene.index.NumericDocValues;
27-
import org.apache.lucene.index.VectorEncoding;
2827
import org.apache.lucene.search.comparators.DoubleComparator;
2928
import org.apache.lucene.util.NumericUtils;
3029

lucene/core/src/java/org/apache/lucene/search/FloatVectorSimilarityValuesSource.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
*/
3434
class FloatVectorSimilarityValuesSource extends VectorSimilarityValuesSource {
3535

36-
/** Creates a {@link FloatVectorSimilarityValuesSource} that scores on full precision vector values */
36+
/**
37+
* Creates a {@link FloatVectorSimilarityValuesSource} that scores on full precision vector values
38+
*/
3739
public static DoubleValues fullPrecisionScores(
3840
LeafReaderContext ctx, float[] queryVector, String vectorField) throws IOException {
39-
return new FloatVectorSimilarityValuesSource(queryVector, vectorField, true).getValues(ctx, null);
41+
return new FloatVectorSimilarityValuesSource(queryVector, vectorField, true)
42+
.getValues(ctx, null);
4043
}
4144

4245
private final float[] queryVector;

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ public void testFullPrecisionVectorSimilarityDVS() throws Exception {
148148
float[] queryVector = TestVectorUtil.randomVector(VECTOR_DIMENSION);
149149
try (IndexReader reader = DirectoryReader.open(dir)) {
150150
for (LeafReaderContext ctx : reader.leaves()) {
151-
DoubleValues fpSimValues = FloatVectorSimilarityValuesSource.fullPrecisionScores(ctx, queryVector, KNN_FIELD);
152-
DoubleValues quantizedSimValues = DoubleValuesSource.similarityToQueryVector(ctx, queryVector, KNN_FIELD);
151+
DoubleValues fpSimValues =
152+
FloatVectorSimilarityValuesSource.fullPrecisionScores(ctx, queryVector, KNN_FIELD);
153+
DoubleValues quantizedSimValues =
154+
DoubleValuesSource.similarityToQueryVector(ctx, queryVector, KNN_FIELD);
153155
// validate when segment has no vectors
154156
if (fpSimValues == DoubleValues.EMPTY || quantizedSimValues == DoubleValues.EMPTY) {
155157
assertEquals(fpSimValues, quantizedSimValues);
@@ -195,9 +197,9 @@ public void testFullPrecisionByteVectorSimilarityDVS() throws Exception {
195197

196198
// index some 4 bit quantized vectors
197199
try (IndexWriter w =
198-
new IndexWriter(
199-
dir,
200-
newIndexWriterConfig().setCodec(TestUtil.alwaysKnnVectorsFormat(getKnnFormat(4))))) {
200+
new IndexWriter(
201+
dir,
202+
newIndexWriterConfig().setCodec(TestUtil.alwaysKnnVectorsFormat(getKnnFormat(4))))) {
201203
for (int j = 0; j < numSegments; j++) {
202204
for (int i = 0; i < numVectors; i++) {
203205
Document doc = new Document();
@@ -226,9 +228,9 @@ public void testFullPrecisionByteVectorSimilarityDVS() throws Exception {
226228

227229
// index some 7 bit quantized vectors
228230
try (IndexWriter w =
229-
new IndexWriter(
230-
dir,
231-
newIndexWriterConfig().setCodec(TestUtil.alwaysKnnVectorsFormat(getKnnFormat(7))))) {
231+
new IndexWriter(
232+
dir,
233+
newIndexWriterConfig().setCodec(TestUtil.alwaysKnnVectorsFormat(getKnnFormat(7))))) {
232234
for (int j = 0; j < numSegments; j++) {
233235
for (int i = 0; i < numVectors; i++) {
234236
Document doc = new Document();
@@ -258,8 +260,10 @@ public void testFullPrecisionByteVectorSimilarityDVS() throws Exception {
258260
byte[] queryVector = TestVectorUtil.randomVectorBytes(VECTOR_DIMENSION);
259261
try (IndexReader reader = DirectoryReader.open(dir)) {
260262
for (LeafReaderContext ctx : reader.leaves()) {
261-
DoubleValues fpSimValues = ByteVectorSimilarityValuesSource.fullPrecisionScores(ctx, queryVector, KNN_FIELD);
262-
DoubleValues quantizedSimValues = DoubleValuesSource.similarityToQueryVector(ctx, queryVector, KNN_FIELD);
263+
DoubleValues fpSimValues =
264+
ByteVectorSimilarityValuesSource.fullPrecisionScores(ctx, queryVector, KNN_FIELD);
265+
DoubleValues quantizedSimValues =
266+
DoubleValuesSource.similarityToQueryVector(ctx, queryVector, KNN_FIELD);
263267
// validate when segment has no vectors
264268
if (fpSimValues == DoubleValues.EMPTY || quantizedSimValues == DoubleValues.EMPTY) {
265269
assertEquals(fpSimValues, quantizedSimValues);

0 commit comments

Comments
 (0)