Skip to content

Commit

Permalink
Simplify Codec
Browse files Browse the repository at this point in the history
  • Loading branch information
dungba88 committed Nov 22, 2024
1 parent 22288e5 commit feda6af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@

org.apache.lucene.codecs.TestMinimalCodec$MinimalCodec
org.apache.lucene.codecs.TestMinimalCodec$MinimalCompoundCodec
org.apache.lucene.search.TestRerankKnnFloatVectorQuery$QuantizedCodec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
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;
Expand All @@ -35,6 +32,7 @@
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;
Expand All @@ -58,7 +56,8 @@ public void setUp() throws Exception {

// Set up the IndexWriterConfig to use quantized vector storage
config = new IndexWriterConfig();
config.setCodec(new QuantizedCodec());
config.setCodec(
TestUtil.alwaysKnnVectorsFormat(new Lucene99HnswScalarQuantizedVectorsFormat()));
}

@Test
Expand Down Expand Up @@ -122,16 +121,4 @@ private float[] randomFloatVector(int dimension, Random random) {
}
return vector;
}

public static class QuantizedCodec extends FilterCodec {

public QuantizedCodec() {
super("QuantizedCodec", new Lucene100Codec());
}

@Override
public KnnVectorsFormat knnVectorsFormat() {
return new Lucene99HnswScalarQuantizedVectorsFormat();
}
}
}

0 comments on commit feda6af

Please sign in to comment.