use of org.apache.asterix.om.functions.IFunctionDescriptorFactory in project asterixdb by apache.
the class NullMissingTest method test.
@Test
public void test() throws Exception {
List<IFunctionDescriptorFactory> functions = FunctionCollection.getFunctionDescriptorFactories();
int testedFunctions = 0;
for (IFunctionDescriptorFactory func : functions) {
String className = func.getClass().getName();
// record and cast functions, which requires type settings (we test them in runtime tests).
if (className.contains("Gen") && !className.contains("record") && !className.contains("Cast")) {
testFunction(func);
++testedFunctions;
}
}
// 208 is the current number of functions with generated code.
Assert.assertTrue(testedFunctions >= 208);
}
use of org.apache.asterix.om.functions.IFunctionDescriptorFactory in project asterixdb by apache.
the class FunctionCollection method getGeneratedFunctionDescriptorFactory.
/**
* Gets the generated function descriptor factory from an <code>IFunctionDescriptor</code>
* implementation class.
*
* @param cl,
* the class of an <code>IFunctionDescriptor</code> implementation.
* @return the IFunctionDescriptorFactory instance defined in the class.
*/
private static IFunctionDescriptorFactory getGeneratedFunctionDescriptorFactory(Class<?> cl) {
try {
String className = CodeGenUtil.getGeneratedFunctionDescriptorClassName(cl.getName(), CodeGenUtil.DEFAULT_SUFFIX_FOR_GENERATED_CLASS);
Class<?> generatedCl = cl.getClassLoader().loadClass(className);
Field factory = generatedCl.getDeclaredField(FACTORY);
return (IFunctionDescriptorFactory) factory.get(null);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
use of org.apache.asterix.om.functions.IFunctionDescriptorFactory in project asterixdb by apache.
the class ExceptionIT method test.
@Test
public void test() throws Exception {
List<IFunctionDescriptorFactory> functions = FunctionCollection.getFunctionDescriptorFactories();
int testedFunctions = 0;
for (IFunctionDescriptorFactory func : functions) {
String className = func.getClass().getName();
// record and cast functions, which requires type settings.
if (className.contains("Gen") && !className.contains("record") && !className.contains("Cast")) {
testFunction(func);
++testedFunctions;
}
}
// 208 is the current number of functions with generated code.
Assert.assertTrue(testedFunctions >= 208);
}
use of org.apache.asterix.om.functions.IFunctionDescriptorFactory 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.IFunctionDescriptorFactory in project asterixdb by apache.
the class FunctionManagerImpl method lookupFunction.
@Override
public synchronized IFunctionDescriptor lookupFunction(FunctionIdentifier fid) throws AlgebricksException {
Pair<FunctionIdentifier, Integer> key = new Pair<>(fid, fid.getArity());
IFunctionDescriptorFactory factory = functions.get(key);
if (factory == null) {
throw new AlgebricksException("Inappropriate use of function " + "'" + fid.getName() + "'");
}
return factory.createFunctionDescriptor();
}
Aggregations