Skip to content

Commit 6720384

Browse files
committed
Update for ElementType change
1 parent 61de804 commit 6720384

10 files changed

+29
-24
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public ES93FlatVectorFormat() {
4444
format = new ES93GenericFlatVectorsFormat();
4545
}
4646

47-
public ES93FlatVectorFormat(boolean useBFloat16) {
47+
public ES93FlatVectorFormat(ES93GenericFlatVectorsFormat.ElementType elementType) {
4848
super(NAME);
49-
format = new ES93GenericFlatVectorsFormat(useBFloat16, false);
49+
assert elementType != ES93GenericFlatVectorsFormat.ElementType.BIT : "ES815BitFlatVectorFormat should be used for bits";
50+
format = new ES93GenericFlatVectorsFormat(elementType, false);
5051
}
5152

5253
@Override

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ES93HnswScalarQuantizedVectorsFormat() {
3333
super(NAME);
3434
this.flatVectorsFormat = new ES93ScalarQuantizedFlatVectorsFormat(
3535
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
36-
false,
36+
ES93GenericFlatVectorsFormat.ElementType.STANDARD,
3737
false
3838
);
3939
}
@@ -42,24 +42,24 @@ public ES93HnswScalarQuantizedVectorsFormat(
4242
int maxConn,
4343
int beamWidth,
4444
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding encoding,
45-
boolean useBFloat16,
45+
ES93GenericFlatVectorsFormat.ElementType elementType,
4646
boolean useDirectIO
4747
) {
4848
super(NAME, maxConn, beamWidth);
49-
this.flatVectorsFormat = new ES93ScalarQuantizedFlatVectorsFormat(encoding, useBFloat16, useDirectIO);
49+
this.flatVectorsFormat = new ES93ScalarQuantizedFlatVectorsFormat(encoding, elementType, useDirectIO);
5050
}
5151

5252
public ES93HnswScalarQuantizedVectorsFormat(
5353
int maxConn,
5454
int beamWidth,
5555
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding encoding,
56-
boolean useBFloat16,
56+
ES93GenericFlatVectorsFormat.ElementType elementType,
5757
boolean useDirectIO,
5858
int numMergeWorkers,
5959
ExecutorService mergeExec
6060
) {
6161
super(NAME, maxConn, beamWidth, numMergeWorkers, mergeExec);
62-
this.flatVectorsFormat = new ES93ScalarQuantizedFlatVectorsFormat(encoding, useBFloat16, useDirectIO);
62+
this.flatVectorsFormat = new ES93ScalarQuantizedFlatVectorsFormat(encoding, elementType, useDirectIO);
6363
}
6464

6565
@Override

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ public class ES93ScalarQuantizedFlatVectorsFormat extends FlatVectorsFormat {
3737

3838
public ES93ScalarQuantizedFlatVectorsFormat(
3939
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding encoding,
40-
boolean useBFloat16,
40+
ES93GenericFlatVectorsFormat.ElementType elementType,
4141
boolean useDirectIO
4242
) {
4343
super(NAME);
44+
assert elementType != ES93GenericFlatVectorsFormat.ElementType.BIT : "BIT should not be used with scalar quantization";
4445
this.encoding = encoding;
45-
this.rawVectorFormat = new ES93GenericFlatVectorsFormat(useBFloat16, useDirectIO);
46+
this.rawVectorFormat = new ES93GenericFlatVectorsFormat(elementType, useDirectIO);
4647
}
4748

4849
@Override

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ public class ES93ScalarQuantizedVectorsFormat extends KnnVectorsFormat {
3838
private final FlatVectorsFormat format;
3939

4040
public ES93ScalarQuantizedVectorsFormat() {
41-
this(false, Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT);
41+
this(ES93GenericFlatVectorsFormat.ElementType.STANDARD, Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT);
4242
}
4343

44-
public ES93ScalarQuantizedVectorsFormat(boolean useBFloat16) {
45-
this(useBFloat16, Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT);
44+
public ES93ScalarQuantizedVectorsFormat(ES93GenericFlatVectorsFormat.ElementType elementType) {
45+
this(elementType, Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT);
4646
}
4747

48-
public ES93ScalarQuantizedVectorsFormat(boolean useBFloat16, Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding encoding) {
48+
public ES93ScalarQuantizedVectorsFormat(
49+
ES93GenericFlatVectorsFormat.ElementType elementType,
50+
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding encoding
51+
) {
4952
super(NAME);
50-
this.format = new ES93ScalarQuantizedFlatVectorsFormat(encoding, useBFloat16, false);
53+
this.format = new ES93ScalarQuantizedFlatVectorsFormat(encoding, elementType, false);
5154
}
5255

5356
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ES93FlatBFloat16VectorFormatTests extends BaseBFloat16KnnVectorsFor
4141

4242
@Override
4343
protected Codec getCodec() {
44-
return TestUtil.alwaysKnnVectorsFormat(new ES93FlatVectorFormat(true));
44+
return TestUtil.alwaysKnnVectorsFormat(new ES93FlatVectorFormat(ES93GenericFlatVectorsFormat.ElementType.BFLOAT16));
4545
}
4646

4747
public void testSearchWithVisitedLimit() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ES93FlatVectorFormatTests extends BaseKnnVectorsFormatTestCase {
4040

4141
@Override
4242
protected Codec getCodec() {
43-
return TestUtil.alwaysKnnVectorsFormat(new ES93FlatVectorFormat(false));
43+
return TestUtil.alwaysKnnVectorsFormat(new ES93FlatVectorFormat(ES93GenericFlatVectorsFormat.ElementType.STANDARD));
4444
}
4545

4646
public void testSearchWithVisitedLimit() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected KnnVectorsFormat createFormat() {
3434
DEFAULT_MAX_CONN,
3535
DEFAULT_BEAM_WIDTH,
3636
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
37-
true,
37+
ES93GenericFlatVectorsFormat.ElementType.BFLOAT16,
3838
random().nextBoolean()
3939
);
4040
}
@@ -45,7 +45,7 @@ protected KnnVectorsFormat createFormat(int maxConn, int beamWidth) {
4545
maxConn,
4646
beamWidth,
4747
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
48-
true,
48+
ES93GenericFlatVectorsFormat.ElementType.BFLOAT16,
4949
random().nextBoolean()
5050
);
5151
}
@@ -56,7 +56,7 @@ protected KnnVectorsFormat createFormat(int maxConn, int beamWidth, int numMerge
5656
maxConn,
5757
beamWidth,
5858
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
59-
true,
59+
ES93GenericFlatVectorsFormat.ElementType.BFLOAT16,
6060
random().nextBoolean(),
6161
numMergeWorkers,
6262
service

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected KnnVectorsFormat createFormat() {
3333
DEFAULT_MAX_CONN,
3434
DEFAULT_BEAM_WIDTH,
3535
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
36-
false,
36+
ES93GenericFlatVectorsFormat.ElementType.STANDARD,
3737
random().nextBoolean()
3838
);
3939
}
@@ -44,7 +44,7 @@ protected KnnVectorsFormat createFormat(int maxConn, int beamWidth) {
4444
maxConn,
4545
beamWidth,
4646
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
47-
false,
47+
ES93GenericFlatVectorsFormat.ElementType.STANDARD,
4848
random().nextBoolean()
4949
);
5050
}
@@ -55,7 +55,7 @@ protected KnnVectorsFormat createFormat(int maxConn, int beamWidth, int numMerge
5555
maxConn,
5656
beamWidth,
5757
Lucene104ScalarQuantizedVectorsFormat.ScalarEncoding.SEVEN_BIT,
58-
false,
58+
ES93GenericFlatVectorsFormat.ElementType.STANDARD,
5959
random().nextBoolean(),
6060
numMergeWorkers,
6161
service

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ES93ScalarQuantizedBFloat16VectorFormatTests extends BaseBFloat16Kn
4646

4747
@Override
4848
public void setUp() throws Exception {
49-
format = new ES93ScalarQuantizedVectorsFormat(true);
49+
format = new ES93ScalarQuantizedVectorsFormat(ES93GenericFlatVectorsFormat.ElementType.BFLOAT16);
5050
super.setUp();
5151
}
5252

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ES93ScalarQuantizedVectorsFormatTests extends BaseKnnVectorsFormatT
4242

4343
@Override
4444
protected Codec getCodec() {
45-
return TestUtil.alwaysKnnVectorsFormat(new ES93ScalarQuantizedVectorsFormat(false));
45+
return TestUtil.alwaysKnnVectorsFormat(new ES93ScalarQuantizedVectorsFormat(ES93GenericFlatVectorsFormat.ElementType.STANDARD));
4646
}
4747

4848
public void testSearchWithVisitedLimit() {

0 commit comments

Comments
 (0)