Skip to content

Commit c909699

Browse files
committed
IndexOptions don't need to implement Writeable
1 parent 2cc4191 commit c909699

File tree

3 files changed

+2
-102
lines changed

3 files changed

+2
-102
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/SemanticTextIndexOptions.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import org.elasticsearch.ElasticsearchException;
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.common.io.stream.StreamInput;
15-
import org.elasticsearch.common.io.stream.StreamOutput;
16-
import org.elasticsearch.common.io.stream.Writeable;
1715
import org.elasticsearch.common.xcontent.support.XContentMapValues;
1816
import org.elasticsearch.index.IndexVersion;
1917
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
@@ -35,7 +33,7 @@
3533
* }
3634
* }
3735
*/
38-
public class SemanticTextIndexOptions implements ToXContent, Writeable {
36+
public class SemanticTextIndexOptions implements ToXContent {
3937

4038
private static final String TYPE_FIELD = "type";
4139

@@ -52,12 +50,6 @@ public SemanticTextIndexOptions(StreamInput in) throws IOException {
5250
this.indexOptions = IndexOptions.readIndexOptions(in);
5351
}
5452

55-
@Override
56-
public void writeTo(StreamOutput out) throws IOException {
57-
out.writeString(type.value);
58-
indexOptions.writeTo(out);
59-
}
60-
6153
public SupportedIndexOptions type() {
6254
return type;
6355
}

server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,15 +1342,6 @@ final boolean validateElementType(ElementType elementType, boolean throwOnError)
13421342
return validElementType;
13431343
}
13441344

1345-
@Override
1346-
public void writeTo(StreamOutput out) throws IOException {
1347-
super.writeTo(out);
1348-
out.writeEnum(type);
1349-
doWriteTo(out);
1350-
}
1351-
1352-
protected abstract void doWriteTo(StreamOutput out) throws IOException;
1353-
13541345
public abstract boolean updatableTo(DenseVectorIndexOptions update);
13551346

13561347
public boolean validateDimension(int dim) {
@@ -1403,13 +1394,6 @@ abstract static class QuantizedIndexOptions extends DenseVectorIndexOptions {
14031394
super(in);
14041395
this.rescoreVector = in.readOptionalWriteable(RescoreVector::new);
14051396
}
1406-
1407-
@Override
1408-
public void writeTo(StreamOutput out) throws IOException {
1409-
super.writeTo(out);
1410-
out.writeOptionalWriteable(rescoreVector);
1411-
doWriteTo(out);
1412-
}
14131397
}
14141398

14151399
public enum VectorIndexType {
@@ -1742,12 +1726,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
17421726
return new Int8FlatIndexOptions(in);
17431727
}
17441728

1745-
@Override
1746-
public void doWriteTo(StreamOutput out) throws IOException {
1747-
super.writeTo(out);
1748-
out.writeOptionalFloat(confidenceInterval);
1749-
}
1750-
17511729
@Override
17521730
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
17531731
builder.startObject();
@@ -1804,11 +1782,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
18041782
return new FlatIndexOptions(in);
18051783
}
18061784

1807-
@Override
1808-
public void doWriteTo(StreamOutput out) throws IOException {
1809-
// no additional fields to write
1810-
}
1811-
18121785
@Override
18131786
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
18141787
builder.startObject();
@@ -1867,14 +1840,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
18671840
return new Int4HnswIndexOptions(in);
18681841
}
18691842

1870-
@Override
1871-
public void doWriteTo(StreamOutput out) throws IOException {
1872-
super.writeTo(out);
1873-
out.writeInt(m);
1874-
out.writeInt(efConstruction);
1875-
out.writeFloat(confidenceInterval);
1876-
}
1877-
18781843
@Override
18791844
public KnnVectorsFormat getVectorsFormat(ElementType elementType) {
18801845
assert elementType == ElementType.FLOAT;
@@ -1957,11 +1922,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
19571922
return new Int4FlatIndexOptions(in);
19581923
}
19591924

1960-
@Override
1961-
public void doWriteTo(StreamOutput out) throws IOException {
1962-
out.writeFloat(confidenceInterval);
1963-
}
1964-
19651925
@Override
19661926
public KnnVectorsFormat getVectorsFormat(ElementType elementType) {
19671927
assert elementType == ElementType.FLOAT;
@@ -2033,13 +1993,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
20331993
return new Int8HnswIndexOptions(in);
20341994
}
20351995

2036-
@Override
2037-
public void doWriteTo(StreamOutput out) throws IOException {
2038-
out.writeInt(m);
2039-
out.writeInt(efConstruction);
2040-
out.writeFloat(confidenceInterval);
2041-
}
2042-
20431996
@Override
20441997
public KnnVectorsFormat getVectorsFormat(ElementType elementType) {
20451998
assert elementType == ElementType.FLOAT;
@@ -2132,12 +2085,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
21322085
return new HnswIndexOptions(in);
21332086
}
21342087

2135-
@Override
2136-
public void doWriteTo(StreamOutput out) throws IOException {
2137-
out.writeInt(m);
2138-
out.writeInt(efConstruction);
2139-
}
2140-
21412088
@Override
21422089
public KnnVectorsFormat getVectorsFormat(ElementType elementType) {
21432090
if (elementType == ElementType.BIT) {
@@ -2209,12 +2156,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
22092156
return new BBQHnswIndexOptions(in);
22102157
}
22112158

2212-
@Override
2213-
public void doWriteTo(StreamOutput out) throws IOException {
2214-
out.writeInt(m);
2215-
out.writeInt(efConstruction);
2216-
}
2217-
22182159
@Override
22192160
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
22202161
assert elementType == ElementType.FLOAT;
@@ -2278,11 +2219,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
22782219
return new BBQFlatIndexOptions(in);
22792220
}
22802221

2281-
@Override
2282-
public void doWriteTo(StreamOutput out) throws IOException {
2283-
// no additional fields to write
2284-
}
2285-
22862222
@Override
22872223
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
22882224
assert elementType == ElementType.FLOAT;
@@ -2349,13 +2285,6 @@ public IndexOptions readFrom(StreamInput in) throws IOException {
23492285
return new BBQIVFIndexOptions(in);
23502286
}
23512287

2352-
@Override
2353-
public void doWriteTo(StreamOutput out) throws IOException {
2354-
super.writeTo(out);
2355-
out.writeVInt(clusterSize);
2356-
out.writeVInt(defaultNProbe);
2357-
}
2358-
23592288
@Override
23602289
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
23612290
assert elementType == ElementType.FLOAT;
@@ -2979,19 +2908,6 @@ public FieldMapper.Builder getMergeBuilder() {
29792908
return new Builder(leafName(), indexCreatedVersion).init(this);
29802909
}
29812910

2982-
@Override
2983-
public void doValidate(MappingLookup mappers) {
2984-
if (indexOptions instanceof BBQIVFIndexOptions && mappers.nestedLookup().getNestedParent(fullPath()) != null) {
2985-
throw new IllegalArgumentException(
2986-
"["
2987-
+ CONTENT_TYPE
2988-
+ "] fields with index type ["
2989-
+ indexOptions.type
2990-
+ "] cannot be indexed if they're within [nested] mappings"
2991-
);
2992-
}
2993-
}
2994-
29952911
private static DenseVectorIndexOptions parseIndexOptions(String fieldName, Object propNode, IndexVersion indexVersion) {
29962912
@SuppressWarnings("unchecked")
29972913
Map<String, ?> indexOptionsMap = (Map<String, ?>) propNode;

server/src/main/java/org/elasticsearch/index/mapper/vectors/IndexOptions.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,12 @@
1919
/**
2020
* Represents general index options that can be attached to a semantic or vector field.
2121
*/
22-
public abstract class IndexOptions implements ToXContent, Writeable {
22+
public abstract class IndexOptions implements ToXContent {
2323

2424
public IndexOptions() {}
2525

2626
public abstract IndexOptions readFrom(StreamInput in) throws IOException;
2727

28-
@Override
29-
public void writeTo(StreamOutput out) throws IOException {
30-
out.writeString(getClass().getName());
31-
doWriteTo(out);
32-
}
33-
34-
protected abstract void doWriteTo(StreamOutput out) throws IOException;
35-
3628
public static IndexOptions readIndexOptions(StreamInput in) throws IOException {
3729
String className = in.readString(); // Read the class name from the input
3830
try {

0 commit comments

Comments
 (0)