Skip to content

Commit 8bfeb84

Browse files
committed
PR comments
1 parent 8f7312c commit 8bfeb84

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/es93/ES93GenericFlatVectorsReader.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.apache.lucene.codecs.CodecUtil;
1313
import org.apache.lucene.codecs.hnsw.FlatVectorsReader;
14-
import org.apache.lucene.codecs.hnsw.FlatVectorsScorer;
1514
import org.apache.lucene.index.ByteVectorValues;
1615
import org.apache.lucene.index.CorruptIndexException;
1716
import org.apache.lucene.index.FieldInfo;
@@ -39,7 +38,7 @@ class ES93GenericFlatVectorsReader extends FlatVectorsReader {
3938
SegmentReadState state,
4039
GenericFlatVectorReaders.LoadFlatVectorsReader loadReader
4140
) throws IOException {
42-
super(null); // we can set this properly with flexible constructor bodies
41+
super(null); // this is not actually used by anything
4342

4443
this.fieldInfos = state.fieldInfos;
4544
this.genericReaders = new GenericFlatVectorReaders();
@@ -96,12 +95,6 @@ record FieldEntry(String rawVectorFormatName, boolean useDirectIOReads) implemen
9695
}
9796
}
9897

99-
@Override
100-
public FlatVectorsScorer getFlatVectorScorer() {
101-
// just go with the first one
102-
return genericReaders.allReaders().iterator().next().getFlatVectorScorer();
103-
}
104-
10598
@Override
10699
public FlatVectorsReader getMergeInstance() throws IOException {
107100
return new ES93GenericFlatVectorsReader(fieldInfos, genericReaders.getMergeInstance());

server/src/main/java/org/elasticsearch/index/codec/vectors/es93/ES93HnswBinaryQuantizedVectorsFormat.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ public ES93HnswBinaryQuantizedVectorsFormat() {
4444
flatVectorsFormat = new ES93BinaryQuantizedVectorsFormat();
4545
}
4646

47-
/**
48-
* Constructs a format using the given graph construction parameters.
49-
*
50-
* @param maxConn the maximum number of connections to a node in the HNSW graph
51-
* @param beamWidth the size of the queue maintained during graph construction.
52-
*/
53-
public ES93HnswBinaryQuantizedVectorsFormat(int maxConn, int beamWidth) {
54-
super(NAME, maxConn, beamWidth);
55-
flatVectorsFormat = new ES93BinaryQuantizedVectorsFormat();
56-
}
57-
5847
/**
5948
* Constructs a format using the given graph construction parameters.
6049
*

server/src/test/java/org/elasticsearch/index/codec/vectors/es93/ES93HnswBinaryQuantizedVectorsFormatTests.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import java.util.Locale;
5353

5454
import static java.lang.String.format;
55+
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_BEAM_WIDTH;
56+
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_MAX_CONN;
5557
import static org.apache.lucene.index.VectorSimilarityFunction.DOT_PRODUCT;
5658
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
5759
import static org.hamcrest.Matchers.either;
@@ -64,11 +66,17 @@ public class ES93HnswBinaryQuantizedVectorsFormatTests extends BaseKnnVectorsFor
6466
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
6567
}
6668

67-
static final Codec codec = TestUtil.alwaysKnnVectorsFormat(new ES93HnswBinaryQuantizedVectorsFormat());
69+
private KnnVectorsFormat format;
70+
71+
@Override
72+
public void setUp() throws Exception {
73+
format = new ES93HnswBinaryQuantizedVectorsFormat(DEFAULT_MAX_CONN, DEFAULT_BEAM_WIDTH, random().nextBoolean());
74+
super.setUp();
75+
}
6876

6977
@Override
7078
protected Codec getCodec() {
71-
return codec;
79+
return TestUtil.alwaysKnnVectorsFormat(format);
7280
}
7381

7482
public void testToString() {
@@ -129,12 +137,12 @@ public void testSingleVectorCase() throws Exception {
129137
}
130138

131139
public void testLimits() {
132-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(-1, 20));
133-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(0, 20));
134-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, 0));
135-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, -1));
136-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(512 + 1, 20));
137-
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, 3201));
140+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(-1, 20, false));
141+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(0, 20, false));
142+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, 0, false));
143+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, -1, false));
144+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(512 + 1, 20, false));
145+
expectThrows(IllegalArgumentException.class, () -> new ES93HnswBinaryQuantizedVectorsFormat(20, 3201, false));
138146
expectThrows(
139147
IllegalArgumentException.class,
140148
() -> new ES93HnswBinaryQuantizedVectorsFormat(20, 100, false, 1, new SameThreadExecutorService())

0 commit comments

Comments
 (0)