Skip to content

Commit 1dff3eb

Browse files
authored
[ML] adjusting preprocessor bwc serialization (#59702)
1 parent 902c1fa commit 1dff3eb

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/FrequencyEncoding.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.elasticsearch.xpack.core.ml.inference.preprocessing;
77

88
import org.apache.lucene.util.RamUsageEstimator;
9-
import org.elasticsearch.Version;
109
import org.elasticsearch.common.ParseField;
1110
import org.elasticsearch.common.Strings;
1211
import org.elasticsearch.common.io.stream.StreamInput;
@@ -79,11 +78,7 @@ public FrequencyEncoding(StreamInput in) throws IOException {
7978
this.field = in.readString();
8079
this.featureName = in.readString();
8180
this.frequencyMap = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readDouble));
82-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
83-
this.custom = in.readBoolean();
84-
} else {
85-
this.custom = false;
86-
}
81+
this.custom = in.readBoolean();
8782
}
8883

8984
/**
@@ -151,9 +146,7 @@ public void writeTo(StreamOutput out) throws IOException {
151146
out.writeString(field);
152147
out.writeString(featureName);
153148
out.writeMap(frequencyMap, StreamOutput::writeString, StreamOutput::writeDouble);
154-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
155-
out.writeBoolean(custom);
156-
}
149+
out.writeBoolean(custom);
157150
}
158151

159152
@Override

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/OneHotEncoding.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.elasticsearch.xpack.core.ml.inference.preprocessing;
77

88
import org.apache.lucene.util.RamUsageEstimator;
9-
import org.elasticsearch.Version;
109
import org.elasticsearch.common.ParseField;
1110
import org.elasticsearch.common.Strings;
1211
import org.elasticsearch.common.io.stream.StreamInput;
@@ -72,11 +71,7 @@ public OneHotEncoding(String field, Map<String, String> hotMap, Boolean custom)
7271
public OneHotEncoding(StreamInput in) throws IOException {
7372
this.field = in.readString();
7473
this.hotMap = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
75-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
76-
this.custom = in.readBoolean();
77-
} else {
78-
this.custom = false;
79-
}
74+
this.custom = in.readBoolean();
8075
}
8176

8277
/**
@@ -139,9 +134,7 @@ public String getWriteableName() {
139134
public void writeTo(StreamOutput out) throws IOException {
140135
out.writeString(field);
141136
out.writeMap(hotMap, StreamOutput::writeString, StreamOutput::writeString);
142-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
143-
out.writeBoolean(custom);
144-
}
137+
out.writeBoolean(custom);
145138
}
146139

147140
@Override

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/preprocessing/TargetMeanEncoding.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package org.elasticsearch.xpack.core.ml.inference.preprocessing;
77

88
import org.apache.lucene.util.RamUsageEstimator;
9-
import org.elasticsearch.Version;
109
import org.elasticsearch.common.ParseField;
1110
import org.elasticsearch.common.Strings;
1211
import org.elasticsearch.common.io.stream.StreamInput;
@@ -83,11 +82,7 @@ public TargetMeanEncoding(StreamInput in) throws IOException {
8382
this.featureName = in.readString();
8483
this.meanMap = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readDouble));
8584
this.defaultValue = in.readDouble();
86-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
87-
this.custom = in.readBoolean();
88-
} else {
89-
this.custom = false;
90-
}
85+
this.custom = in.readBoolean();
9186
}
9287

9388
/**
@@ -163,9 +158,7 @@ public void writeTo(StreamOutput out) throws IOException {
163158
out.writeString(featureName);
164159
out.writeMap(meanMap, StreamOutput::writeString, StreamOutput::writeDouble);
165160
out.writeDouble(defaultValue);
166-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
167-
out.writeBoolean(custom);
168-
}
161+
out.writeBoolean(custom);
169162
}
170163

171164
@Override

0 commit comments

Comments
 (0)