Skip to content

Commit 0df634b

Browse files
authored
Remove deprecated constructor from MetadataAttribute (#129309)
1 parent efca20e commit 0df634b

File tree

1 file changed

+21
-43
lines changed

1 file changed

+21
-43
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/MetadataAttribute.java

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -69,53 +69,13 @@ public MetadataAttribute(Source source, String name, DataType dataType, boolean
6969
this(source, name, dataType, Nullability.TRUE, null, false, searchable);
7070
}
7171

72-
@Deprecated
73-
/**
74-
* Old constructor from when this had a qualifier string. Still needed to not break serialization.
75-
*/
76-
private MetadataAttribute(
77-
Source source,
78-
String name,
79-
DataType dataType,
80-
@Nullable String qualifier,
81-
Nullability nullability,
82-
@Nullable NameId id,
83-
boolean synthetic,
84-
boolean searchable
85-
) {
86-
this(source, name, dataType, nullability, id, synthetic, searchable);
87-
}
88-
89-
@SuppressWarnings("unchecked")
90-
private MetadataAttribute(StreamInput in) throws IOException {
91-
/*
92-
* The funny casting dance with `(StreamInput & PlanStreamInput) in` is required
93-
* because we're in esql-core here and the real PlanStreamInput is in
94-
* esql-proper. And because NamedWriteableRegistry.Entry needs StreamInput,
95-
* not a PlanStreamInput. And we need PlanStreamInput to handle Source
96-
* and NameId. This should become a hard cast when we move everything out
97-
* of esql-core.
98-
*/
99-
this(
100-
Source.readFrom((StreamInput & PlanStreamInput) in),
101-
in.readString(),
102-
DataType.readFrom(in),
103-
in.readOptionalString(),
104-
in.readEnum(Nullability.class),
105-
NameId.readFrom((StreamInput & PlanStreamInput) in),
106-
in.readBoolean(),
107-
in.readBoolean()
108-
);
109-
}
110-
11172
@Override
11273
public void writeTo(StreamOutput out) throws IOException {
11374
if (((PlanStreamOutput) out).writeAttributeCacheHeader(this)) {
11475
Source.EMPTY.writeTo(out);
11576
out.writeString(name());
11677
dataType().writeTo(out);
117-
// We used to write the qualifier here. We can still do if needed in the future.
118-
out.writeOptionalString(null);
78+
out.writeOptionalString(null); // qualifier, no longer used
11979
out.writeEnum(nullable());
12080
id().writeTo(out);
12181
out.writeBoolean(synthetic());
@@ -124,7 +84,25 @@ public void writeTo(StreamOutput out) throws IOException {
12484
}
12585

12686
public static MetadataAttribute readFrom(StreamInput in) throws IOException {
127-
return ((PlanStreamInput) in).readAttributeWithCache(MetadataAttribute::new);
87+
/*
88+
* The funny casting dance with `(StreamInput & PlanStreamInput) in` is required
89+
* because we're in esql-core here and the real PlanStreamInput is in
90+
* esql-proper. And because NamedWriteableRegistry.Entry needs StreamInput,
91+
* not a PlanStreamInput. And we need PlanStreamInput to handle Source
92+
* and NameId. This should become a hard cast when we move everything out
93+
* of esql-core.
94+
*/
95+
return ((PlanStreamInput) in).readAttributeWithCache(stream -> {
96+
Source source = Source.readFrom((StreamInput & PlanStreamInput) stream);
97+
String name = stream.readString();
98+
DataType dataType = DataType.readFrom(stream);
99+
String qualifier = stream.readOptionalString(); // qualifier, no longer used
100+
Nullability nullability = stream.readEnum(Nullability.class);
101+
NameId id = NameId.readFrom((StreamInput & PlanStreamInput) stream);
102+
boolean synthetic = stream.readBoolean();
103+
boolean searchable = stream.readBoolean();
104+
return new MetadataAttribute(source, name, dataType, nullability, id, synthetic, searchable);
105+
});
128106
}
129107

130108
@Override
@@ -134,7 +112,7 @@ public String getWriteableName() {
134112

135113
@Override
136114
protected MetadataAttribute clone(Source source, String name, DataType type, Nullability nullability, NameId id, boolean synthetic) {
137-
return new MetadataAttribute(source, name, type, null, nullability, id, synthetic, searchable);
115+
return new MetadataAttribute(source, name, type, nullability, id, synthetic, searchable);
138116
}
139117

140118
@Override

0 commit comments

Comments
 (0)