if (!sourceCall.getInput().next(context[0], context[1])) {
return false;
}
TupleEntry entry = sourceCall.getIncomingEntry();
Map data = (Map) context[1];
FieldAlias alias = (FieldAlias) context[2];
if (entry.getFields().isDefined()) {
// lookup using writables
Text lookupKey = new Text();
// TODO: it's worth benchmarking whether using an index/offset yields significantly better performance
for (Comparable<?> field : entry.getFields()) {
if (IS_ES_10) {
// check for multi-level alias
Object result = data;
for (String level : StringUtils.tokenize(alias.toES(field.toString()), ".")) {
lookupKey.set(level);
result = ((Map) result).get(lookupKey);
if (result == null) {
break;
}
}
CascadingUtils.setObject(entry, field, result);
}
else {
lookupKey.set(alias.toES(field.toString()));
CascadingUtils.setObject(entry, field, data.get(lookupKey));
}
}
}
else {
// no definition means no coercion
List<Object> elements = Tuple.elements(entry.getTuple());
elements.clear();
elements.addAll(data.values());
}
return true;