From e89c06341debdec62d43bc6eeee440946f6af1f0 Mon Sep 17 00:00:00 2001 From: yuye-aws Date: Fri, 8 Mar 2024 23:36:06 +0800 Subject: [PATCH] resolve code review comments Signed-off-by: yuye-aws --- .../neuralsearch/processor/DocumentChunkingProcessor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/DocumentChunkingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/DocumentChunkingProcessor.java index 2dcd8acb1..63d04a505 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/DocumentChunkingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/DocumentChunkingProcessor.java @@ -130,8 +130,8 @@ private void validateAndParseAlgorithmMap(Map algorithmMap) { this.chunkerType = algorithmKey; this.chunkerParameters = (Map) algorithmValue; chunker.validateParameters(chunkerParameters); - if (((Map) algorithmValue).containsKey(MAX_CHUNK_LIMIT_FIELD)) { - String maxChunkLimitString = ((Map) algorithmValue).get(MAX_CHUNK_LIMIT_FIELD).toString(); + if (chunkerParameters.containsKey(MAX_CHUNK_LIMIT_FIELD)) { + String maxChunkLimitString = chunkerParameters.get(MAX_CHUNK_LIMIT_FIELD).toString(); if (!(NumberUtils.isParsable(maxChunkLimitString))) { throw new IllegalArgumentException( "Parameter [" + MAX_CHUNK_LIMIT_FIELD + "] cannot be cast to [" + Number.class.getName() + "]" @@ -147,7 +147,7 @@ private void validateAndParseAlgorithmMap(Map algorithmMap) { } @SuppressWarnings("unchecked") - private boolean isListString(Object value) { + private boolean isListOfString(Object value) { // an empty list is also List if (!(value instanceof List)) { return false; @@ -191,7 +191,7 @@ private List chunkLeafType(Object value, ChunkCountWrapper chunkCountWra List chunkedResult = null; if (value instanceof String) { chunkedResult = chunkString(value.toString(), chunkCountWrapper); - } else if (isListString(value)) { + } else if (isListOfString(value)) { chunkedResult = chunkList((List) value, chunkCountWrapper); } return chunkedResult;