Skip to content

Commit

Permalink
Moved parsinf of nested map configs to constructor
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Jul 8, 2024
1 parent da9342d commit b27cb49
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public abstract class InferenceProcessor extends AbstractProcessor {

private final Environment environment;
private final ClusterService clusterService;
List<Pair<String, Object>> mappingForNestedFields;

public InferenceProcessor(
String tag,
Expand All @@ -87,6 +88,7 @@ public InferenceProcessor(
this.mlCommonsClientAccessor = clientAccessor;
this.environment = environment;
this.clusterService = clusterService;
mappingForNestedFields = fieldMap.entrySet().stream().map(this::processNestedKey).collect(Collectors.toList());
}

private void validateEmbeddingConfiguration(Map<String, Object> fieldMap) {
Expand Down Expand Up @@ -282,8 +284,7 @@ private void createInferenceListForMapTypeInput(Object sourceValue, List<String>
Map<String, Object> buildMapWithTargetKeys(IngestDocument ingestDocument) {
Map<String, Object> sourceAndMetadataMap = ingestDocument.getSourceAndMetadata();
Map<String, Object> mapWithProcessorKeys = new LinkedHashMap<>();
for (Map.Entry<String, Object> fieldMapEntry : fieldMap.entrySet()) {
Pair<String, Object> processedNestedKey = processNestedKey(fieldMapEntry);
for (Pair<String, Object> processedNestedKey : mappingForNestedFields) {
String originalKey = processedNestedKey.getKey();
Object targetKey = processedNestedKey.getValue();

Expand Down

0 comments on commit b27cb49

Please sign in to comment.