From c083a7c59a0314017082821789f553022ca1b963 Mon Sep 17 00:00:00 2001 From: Zan Niu Date: Thu, 20 Oct 2022 10:13:38 +0800 Subject: [PATCH] Remove unnecessary empty string checks Signed-off-by: Zan Niu --- .../neuralsearch/processor/TextEmbeddingProcessor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java index b6314e3a7..16f9689c0 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java @@ -114,9 +114,9 @@ private void createInferenceListForMapTypeInput(Object sourceValue, List if (sourceValue instanceof Map) { ((Map) sourceValue).forEach((k, v) -> createInferenceListForMapTypeInput(v, texts)); } else if (sourceValue instanceof List) { - ((List) sourceValue).stream().filter(StringUtils::isNotBlank).forEach(texts::add); + texts.addAll(((List) sourceValue)); } else { - if (sourceValue == null || StringUtils.isBlank(sourceValue.toString())) return; + if (sourceValue == null) return; texts.add(sourceValue.toString()); } } @@ -176,7 +176,7 @@ Map buildTextEmbeddingResult( for (Map.Entry knnMapEntry : knnMap.entrySet()) { String knnKey = knnMapEntry.getKey(); Object sourceValue = knnMapEntry.getValue(); - if (sourceValue instanceof String && StringUtils.isNotBlank(sourceValue.toString())) { + if (sourceValue instanceof String) { List modelTensor = modelTensorList.get(indexWrapper.index++); result.put(knnKey, modelTensor); } else if (sourceValue instanceof List) {