mirror of https://github.com/apache/lucene.git
Don't throw an exception for byte-encoded vectors in SimpleText codec
This commit is contained in:
parent
df67223497
commit
8021c2db4e
|
@ -28,7 +28,6 @@ import org.apache.lucene.index.BufferingKnnVectorsWriter;
|
|||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
import org.apache.lucene.index.SegmentWriteState;
|
||||
import org.apache.lucene.index.VectorEncoding;
|
||||
import org.apache.lucene.index.VectorValues;
|
||||
import org.apache.lucene.store.IndexOutput;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
|
@ -77,10 +76,6 @@ public class SimpleTextKnnVectorsWriter extends BufferingKnnVectorsWriter {
|
|||
public void writeField(FieldInfo fieldInfo, KnnVectorsReader knnVectorsReader, int maxDoc)
|
||||
throws IOException {
|
||||
VectorValues vectors = knnVectorsReader.getVectorValues(fieldInfo.name);
|
||||
if (fieldInfo.getVectorEncoding() != VectorEncoding.FLOAT32) {
|
||||
throw new IllegalArgumentException(
|
||||
"SimpleText codec does not support vector encoding: " + fieldInfo.getVectorEncoding());
|
||||
}
|
||||
long vectorDataOffset = vectorData.getFilePointer();
|
||||
List<Integer> docIds = new ArrayList<>();
|
||||
int docV;
|
||||
|
|
|
@ -17,12 +17,7 @@
|
|||
package org.apache.lucene.codecs.simpletext;
|
||||
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.KnnVectorField;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.VectorEncoding;
|
||||
import org.apache.lucene.index.VectorSimilarityFunction;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.tests.index.BaseKnnVectorsFormatTestCase;
|
||||
|
||||
public class TestSimpleTextKnnVectorsFormat extends BaseKnnVectorsFormatTestCase {
|
||||
|
@ -37,16 +32,6 @@ public class TestSimpleTextKnnVectorsFormat extends BaseKnnVectorsFormatTestCase
|
|||
return VectorEncoding.FLOAT32;
|
||||
}
|
||||
|
||||
public void testUnsupportedEncoding() throws Exception {
|
||||
try (Directory dir = newDirectory();
|
||||
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig())) {
|
||||
Document doc = new Document();
|
||||
doc.add(new KnnVectorField("field", newBytesRef(2), VectorSimilarityFunction.DOT_PRODUCT));
|
||||
iw.addDocument(doc);
|
||||
expectThrows(IllegalArgumentException.class, () -> iw.commit());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testRandomBytes() throws Exception {
|
||||
// unimplemented
|
||||
|
|
Loading…
Reference in New Issue