From cc84dd4f122ad269657fee7140b3b190ff9ebfb3 Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Fri, 20 Dec 2019 14:32:37 -0500 Subject: [PATCH] [ML][Inference] minor cleanup for inference (#50444) --- .../core/ml/inference/InferenceToXContentCompressor.java | 4 ++-- .../xpack/ml/inference/ingest/InferenceProcessor.java | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressor.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressor.java index f2d24c81b8695..96b4eb9d6493a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressor.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/InferenceToXContentCompressor.java @@ -43,8 +43,8 @@ public static String deflate(T objectToCompress) th } static T inflate(String compressedString, - CheckedFunction parserFunction, - NamedXContentRegistry xContentRegistry) throws IOException { + CheckedFunction parserFunction, + NamedXContentRegistry xContentRegistry) throws IOException { try(XContentParser parser = XContentHelper.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, inflate(compressedString, MAX_INFLATED_BYTES), diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java index 18ac57d1ae818..cc2e7997d6318 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java @@ -28,7 +28,6 @@ import org.elasticsearch.ingest.Processor; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.xpack.core.ml.action.InternalInferModelAction; -import org.elasticsearch.xpack.core.ml.inference.results.InferenceResults; import org.elasticsearch.xpack.core.ml.inference.results.WarningInferenceResults; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ClassificationConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.InferenceConfig; @@ -151,12 +150,8 @@ void mutateDocument(InternalInferModelAction.Response response, IngestDocument i if (response.getInferenceResults().isEmpty()) { throw new ElasticsearchStatusException("Unexpected empty inference response", RestStatus.INTERNAL_SERVER_ERROR); } - InferenceResults inferenceResults = response.getInferenceResults().get(0); - if (inferenceResults instanceof WarningInferenceResults) { - inferenceResults.writeResult(ingestDocument, this.targetField); - } else { - response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField); - } + assert response.getInferenceResults().size() == 1; + response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField); ingestDocument.setFieldValue(targetField + "." + MODEL_ID, modelId); }