use of org.apache.asterix.om.functions.IFunctionManager in project asterixdb by apache.
the class AbstractScalarAggregateDescriptor method createEvaluatorFactory.
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) throws AlgebricksException {
// The aggregate function will get a SingleFieldFrameTupleReference that points to the result of the ScanCollection.
// The list-item will always reside in the first field (column) of the SingleFieldFrameTupleReference.
IScalarEvaluatorFactory[] aggFuncArgs = new IScalarEvaluatorFactory[1];
aggFuncArgs[0] = new ColumnAccessEvalFactory(0);
// Create aggregate function from this scalar version.
FunctionIdentifier fid = BuiltinFunctions.getAggregateFunction(getIdentifier());
IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
IFunctionDescriptor fd = mgr.lookupFunction(fid);
AbstractAggregateFunctionDynamicDescriptor aggFuncDesc = (AbstractAggregateFunctionDynamicDescriptor) fd;
final IAggregateEvaluatorFactory aggFuncFactory = aggFuncDesc.createAggregateEvaluatorFactory(aggFuncArgs);
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
// Use ScanCollection to iterate over list items.
ScanCollectionUnnestingFunctionFactory scanCollectionFactory = new ScanCollectionUnnestingFunctionFactory(args[0]);
return new GenericScalarAggregateFunction(aggFuncFactory.createAggregateEvaluator(ctx), scanCollectionFactory, ctx);
}
};
}
use of org.apache.asterix.om.functions.IFunctionManager in project asterixdb by apache.
the class NonTaggedDataFormat method registerRuntimeFunctions.
@Override
public void registerRuntimeFunctions(List<IFunctionDescriptorFactory> funcDescriptors) throws AlgebricksException {
if (registered) {
return;
}
registered = true;
if (FunctionManagerHolder.getFunctionManager() != null) {
return;
}
IFunctionManager mgr = new FunctionManagerImpl();
for (IFunctionDescriptorFactory fdFactory : funcDescriptors) {
mgr.registerFunction(fdFactory);
}
FunctionManagerHolder.setFunctionManager(mgr);
registerTypeInferers();
}
use of org.apache.asterix.om.functions.IFunctionManager in project asterixdb by apache.
the class NonTaggedDataFormat method resolveFunction.
@Override
public IFunctionDescriptor resolveFunction(ILogicalExpression expr, IVariableTypeEnvironment context) throws AlgebricksException {
FunctionIdentifier fnId = ((AbstractFunctionCallExpression) expr).getFunctionIdentifier();
IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
IFunctionDescriptor fd = mgr.lookupFunction(fnId);
if (fd == null) {
throw new AlgebricksException("Unresolved function " + fnId);
}
final FunctionIdentifier fid = fd.getIdentifier();
if (functionTypeInferers.containsKey(fid)) {
functionTypeInferers.get(fid).infer(expr, fd, context);
}
return fd;
}
Aggregations