From b8d001aadf50cd5ae400af72a9e06dc5475f4142 Mon Sep 17 00:00:00 2001 From: "Gopala-Krishna.Char" Date: Wed, 29 Nov 2023 11:41:17 +0100 Subject: [PATCH] spotless formatting Signed-off-by: Gopala-Krishna.Char --- .../processor/InferenceProcessor.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java index 2983e2920..958725451 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/InferenceProcessor.java @@ -209,12 +209,12 @@ private void validateEmbeddingFieldsValue(IngestDocument ingestDocument) { String sourceKey = embeddingFieldsEntry.getKey(); Class sourceValueClass = sourceValue.getClass(); if (List.class.isAssignableFrom(sourceValueClass) || Map.class.isAssignableFrom(sourceValueClass)) { - if(Map.class.isAssignableFrom(embeddingFieldsEntry.getValue().getClass())){ + if (Map.class.isAssignableFrom(embeddingFieldsEntry.getValue().getClass())) { Map innerFieldsEntry = (Map) embeddingFieldsEntry.getValue(); - for(Map.Entry innerKey: innerFieldsEntry.entrySet()){ + for (Map.Entry innerKey : innerFieldsEntry.entrySet()) { validateNestedTypeValue(innerKey.getKey(), sourceValue, () -> 2); } - }else{ + } else { validateNestedTypeValue(sourceKey, sourceValue, () -> 1); } } else if (!String.class.isAssignableFrom(sourceValueClass)) { @@ -232,7 +232,7 @@ private void validateNestedTypeValue(String sourceKey, Object sourceValue, Suppl if (maxDepth > MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING.get(environment.settings())) { throw new IllegalArgumentException("map type field [" + sourceKey + "] reached max depth limit, cannot process it"); } else if ((List.class.isAssignableFrom(sourceValue.getClass()))) { - validateListTypeValue(sourceKey, sourceValue); + validateListTypeValue(sourceKey, sourceValue, maxDepthSupplier); } else if (Map.class.isAssignableFrom(sourceValue.getClass())) { ((Map) sourceValue).values() .stream() @@ -246,11 +246,11 @@ private void validateNestedTypeValue(String sourceKey, Object sourceValue, Suppl } @SuppressWarnings({ "rawtypes" }) - private void validateListTypeValue(String sourceKey, Object sourceValue) { + private void validateListTypeValue(String sourceKey, Object sourceValue, Supplier maxDepthSupplier) { for (Object value : (List) sourceValue) { - if(value instanceof Map){ - validateNestedTypeValue(sourceKey, value, () -> 1); - }else if (value == null) { + if (value instanceof Map) { + validateNestedTypeValue(sourceKey, value, () -> maxDepthSupplier.get() + 1); + } else if (value == null) { throw new IllegalArgumentException("list type field [" + sourceKey + "] has null, cannot process it"); } else if (!(value instanceof String)) { throw new IllegalArgumentException("list type field [" + sourceKey + "] has non string value, cannot process it");