use of org.teiid.core.ComponentNotFoundException in project teiid by teiid.
the class Evaluator method evaluate.
private Object evaluate(Function function, List<?> tuple) throws BlockedException, TeiidComponentException, ExpressionEvaluationException {
// Get function based on resolved function info
FunctionDescriptor fd = function.getFunctionDescriptor();
// Evaluate args
Expression[] args = function.getArgs();
Object[] values = null;
int start = 0;
if (fd.requiresContext()) {
values = new Object[args.length + 1];
values[0] = context;
start = 1;
} else {
values = new Object[args.length];
}
for (int i = 0; i < args.length; i++) {
values[i + start] = internalEvaluate(args[i], tuple);
if (values[i + start] instanceof Constant) {
// $NON-NLS-1$
throw new AssertionError("Multi-valued constant not allowed to be directly evaluated");
}
}
if (fd.getPushdown() == PushDown.MUST_PUSHDOWN) {
try {
return evaluatePushdown(function, tuple, values);
} catch (TeiidProcessingException e) {
throw new ExpressionEvaluationException(e);
}
}
if (fd.getProcedure() != null) {
try {
return evaluateProcedure(function, tuple, values);
} catch (TeiidProcessingException e) {
throw new ExpressionEvaluationException(e);
}
}
// Check for special lookup function
if (function.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
if (dataMgr == null) {
throw new ComponentNotFoundException(QueryPlugin.Event.TEIID30342, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30342));
}
String codeTableName = (String) values[0];
String returnElementName = (String) values[1];
String keyElementName = (String) values[2];
try {
return dataMgr.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, values[3]);
} catch (TeiidProcessingException e) {
throw new ExpressionEvaluationException(e);
}
}
// Execute function
return fd.invokeFunction(values, context, null);
}
Aggregations