Skip to content

Commit 45ad809

Browse files
committed
remove redundant encoding check
1 parent 8bbaab5 commit 45ad809

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,7 @@ public VectorScorer getScorer(LeafReaderContext ctx) throws IOException {
7979
ByteVectorValues.checkField(ctx.reader(), fieldName);
8080
return null;
8181
}
82-
8382
final FieldInfo fi = ctx.reader().getFieldInfos().fieldInfo(fieldName);
84-
if (fi.getVectorEncoding() != VectorEncoding.BYTE) {
85-
throw new IllegalArgumentException(
86-
"Field "
87-
+ fieldName
88-
+ " does not have the expected vector encoding: "
89-
+ VectorEncoding.BYTE);
90-
}
9183
if (fi.getVectorDimension() != queryVector.length) {
9284
throw new IllegalArgumentException(
9385
"Query vector dimension does not match field dimension: "

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,7 @@ public VectorScorer getScorer(LeafReaderContext ctx) throws IOException {
7979
FloatVectorValues.checkField(ctx.reader(), fieldName);
8080
return null;
8181
}
82-
8382
final FieldInfo fi = ctx.reader().getFieldInfos().fieldInfo(fieldName);
84-
if (fi.getVectorEncoding() != VectorEncoding.FLOAT32) {
85-
throw new IllegalArgumentException(
86-
"Field "
87-
+ fieldName
88-
+ " does not have the expected vector encoding: "
89-
+ VectorEncoding.FLOAT32);
90-
}
9183
if (fi.getVectorDimension() != queryVector.length) {
9284
throw new IllegalArgumentException(
9385
"Query vector dimension does not match field dimension: "

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ public void testFailuresWithSimilarityValuesSource() throws Exception {
365365
byte[] byteQueryVector = new byte[] {-10, 20, 30};
366366

367367
expectThrows(
368-
IllegalArgumentException.class,
368+
IllegalStateException.class,
369369
() ->
370370
DoubleValuesSource.similarityToQueryVector(
371371
searcher.reader.leaves().get(0), floatQueryVector, "knnByteField1"));
372372
expectThrows(
373-
IllegalArgumentException.class,
373+
IllegalStateException.class,
374374
() ->
375375
DoubleValuesSource.similarityToQueryVector(
376376
searcher.reader.leaves().get(0), byteQueryVector, "knnFloatField1"));

0 commit comments

Comments
 (0)