Simplify Codec

This commit is contained in:
Anh Dung Bui 2024-11-22 10:05:35 +09:00
parent 22288e5ab0
commit feda6af1a7
2 changed files with 3 additions and 17 deletions

View File

@ -15,4 +15,3 @@
org.apache.lucene.codecs.TestMinimalCodec$MinimalCodec
org.apache.lucene.codecs.TestMinimalCodec$MinimalCompoundCodec
org.apache.lucene.search.TestRerankKnnFloatVectorQuery$QuantizedCodec

View File

@ -19,9 +19,6 @@ package org.apache.lucene.search;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.KnnVectorsFormat;
import org.apache.lucene.codecs.lucene100.Lucene100Codec;
import org.apache.lucene.codecs.lucene99.Lucene99HnswScalarQuantizedVectorsFormat;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -35,6 +32,7 @@ import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.lucene.store.ByteBuffersDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -58,7 +56,8 @@ public class TestRerankKnnFloatVectorQuery extends LuceneTestCase {
// Set up the IndexWriterConfig to use quantized vector storage
config = new IndexWriterConfig();
config.setCodec(new QuantizedCodec());
config.setCodec(
TestUtil.alwaysKnnVectorsFormat(new Lucene99HnswScalarQuantizedVectorsFormat()));
}
@Test
@ -122,16 +121,4 @@ public class TestRerankKnnFloatVectorQuery extends LuceneTestCase {
}
return vector;
}
public static class QuantizedCodec extends FilterCodec {
public QuantizedCodec() {
super("QuantizedCodec", new Lucene100Codec());
}
@Override
public KnnVectorsFormat knnVectorsFormat() {
return new Lucene99HnswScalarQuantizedVectorsFormat();
}
}
}