Skip to content

Commit cc84dd4

Browse files
authored
[ML][Inference] minor cleanup for inference (#50444)
1 parent a311018 commit cc84dd4

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static <T extends ToXContentObject> String deflate(T objectToCompress) th
4343
}
4444

4545
static <T> T inflate(String compressedString,
46-
CheckedFunction<XContentParser, T, IOException> parserFunction,
47-
NamedXContentRegistry xContentRegistry) throws IOException {
46+
CheckedFunction<XContentParser, T, IOException> parserFunction,
47+
NamedXContentRegistry xContentRegistry) throws IOException {
4848
try(XContentParser parser = XContentHelper.createParser(xContentRegistry,
4949
LoggingDeprecationHandler.INSTANCE,
5050
inflate(compressedString, MAX_INFLATED_BYTES),

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.ingest.Processor;
2929
import org.elasticsearch.rest.RestStatus;
3030
import org.elasticsearch.xpack.core.ml.action.InternalInferModelAction;
31-
import org.elasticsearch.xpack.core.ml.inference.results.InferenceResults;
3231
import org.elasticsearch.xpack.core.ml.inference.results.WarningInferenceResults;
3332
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ClassificationConfig;
3433
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.InferenceConfig;
@@ -151,12 +150,8 @@ void mutateDocument(InternalInferModelAction.Response response, IngestDocument i
151150
if (response.getInferenceResults().isEmpty()) {
152151
throw new ElasticsearchStatusException("Unexpected empty inference response", RestStatus.INTERNAL_SERVER_ERROR);
153152
}
154-
InferenceResults inferenceResults = response.getInferenceResults().get(0);
155-
if (inferenceResults instanceof WarningInferenceResults) {
156-
inferenceResults.writeResult(ingestDocument, this.targetField);
157-
} else {
158-
response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField);
159-
}
153+
assert response.getInferenceResults().size() == 1;
154+
response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField);
160155
ingestDocument.setFieldValue(targetField + "." + MODEL_ID, modelId);
161156
}
162157

0 commit comments

Comments
 (0)