Skip to content

Commit

Permalink
fix indexing in inference processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Hwang authored and Will Hwang committed Feb 19, 2025
1 parent fbe4461 commit 9264760
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,18 @@ private void processMapEntryValue(
) {
// build nlp output for object in sourceValue which is map type
Iterator<Map<String, Object>> iterator = sourceAndMetadataMapValueInList.iterator();
IntStream.range(0, sourceAndMetadataMapValueInList.size()).forEach(index -> {
IndexWrapper listIndexWrapper = new IndexWrapper(0);
for (int i = 0; i < sourceAndMetadataMapValueInList.size(); i++) {
Map<String, Object> nestedElement = iterator.next();
putNLPResultToSingleSourceMapInList(
inputNestedMapEntryKey,
inputNestedMapEntryValue,
results,
indexWrapper,
nestedElement,
index
listIndexWrapper
);
});
}
}

/**
Expand All @@ -590,7 +591,7 @@ private void putNLPResultToSingleSourceMapInList(
List<?> results,
IndexWrapper indexWrapper,
Map<String, Object> sourceAndMetadataMap,
int nestedElementIndex
IndexWrapper listIndexWrapper
) {
if (processorKey == null || sourceAndMetadataMap == null || sourceValue == null) return;
if (sourceValue instanceof Map) {
Expand All @@ -603,12 +604,17 @@ private void putNLPResultToSingleSourceMapInList(
results,
indexWrapper,
sourceMap,
nestedElementIndex
listIndexWrapper
);
}
} else {
if (sourceValue instanceof List && ((List<Object>) sourceValue).get(nestedElementIndex) != null) {
sourceAndMetadataMap.merge(processorKey, results.get(indexWrapper.index++), REMAPPING_FUNCTION);
if (sourceValue instanceof List) {
if (sourceAndMetadataMap.containsKey(processorKey)) {
return;
}
if (((List<Object>) sourceValue).get(listIndexWrapper.index++) != null) {
sourceAndMetadataMap.merge(processorKey, results.get(indexWrapper.index++), REMAPPING_FUNCTION);
}
}
}
}
Expand Down

0 comments on commit 9264760

Please sign in to comment.