Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Feb 26, 2024
1 parent 25c9fea commit 9305955
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void validateDocumentChunkingFieldMap(Map<String, Object> fieldMap) {

if (!(parameters instanceof Map)) {
throw new IllegalArgumentException(
"parameters for input field [" + inputField + "] cannot be cast to [" + String.class.getName() + "]"
"parameters for input field [" + inputField + "] cannot be cast to [" + Map.class.getName() + "]"
);
}

Expand Down Expand Up @@ -119,11 +119,8 @@ private void validateDocumentChunkingFieldMap(Map<String, Object> fieldMap) {
}

// should only define one algorithm
if (chunkingAlgorithmCount == 0) {
throw new IllegalArgumentException("chunking algorithm not defined for input field [" + inputField + "]");
}
if (chunkingAlgorithmCount > 1) {
throw new IllegalArgumentException("multiple chunking algorithms defined for input field [" + inputField + "]");
if (chunkingAlgorithmCount != 1) {
throw new IllegalArgumentException("input field [" + inputField + "] should has and only has 1 chunking algorithm");
}
}
}
Expand Down Expand Up @@ -165,14 +162,15 @@ public IngestDocument execute(IngestDocument document) {
);
}

Map<?, ?> parameters = (Map<?, ?>) fieldMapEntry.getValue();
@SuppressWarnings("unchecked")
Map<String, Object> parameters = (Map<String, Object>) fieldMapEntry.getValue();
String outputField = (String) parameters.get(OUTPUT_FIELD);
List<String> chunkedPassages = new ArrayList<>();

// we have validated that there is one chunking algorithm
// and that chunkerParameters is of type Map<String, Object>
for (Map.Entry<?, ?> parameterEntry : parameters.entrySet()) {
String parameterKey = (String) parameterEntry.getKey();
for (Map.Entry<String, Object> parameterEntry : parameters.entrySet()) {
String parameterKey = parameterEntry.getKey();
if (supportedChunkers.contains(parameterKey)) {
@SuppressWarnings("unchecked")
Map<String, Object> chunkerParameters = (Map<String, Object>) parameterEntry.getValue();
Expand Down

0 comments on commit 9305955

Please sign in to comment.