Search in sources :

Example 1 with IFunctionDescriptorFactory

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);
}
Also used : IFunctionDescriptorFactory(org.apache.asterix.om.functions.IFunctionDescriptorFactory) Test(org.junit.Test)

Example 2 with IFunctionDescriptorFactory

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);
    }
}
Also used : Field(java.lang.reflect.Field) IFunctionDescriptorFactory(org.apache.asterix.om.functions.IFunctionDescriptorFactory)

Example 3 with IFunctionDescriptorFactory

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);
}
Also used : IFunctionDescriptorFactory(org.apache.asterix.om.functions.IFunctionDescriptorFactory) Test(org.junit.Test)

Example 4 with IFunctionDescriptorFactory

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();
}
Also used : IFunctionDescriptorFactory(org.apache.asterix.om.functions.IFunctionDescriptorFactory) FunctionManagerImpl(org.apache.asterix.runtime.evaluators.common.FunctionManagerImpl) IFunctionManager(org.apache.asterix.om.functions.IFunctionManager)

Example 5 with IFunctionDescriptorFactory

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();
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) IFunctionDescriptorFactory(org.apache.asterix.om.functions.IFunctionDescriptorFactory) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) Pair(org.apache.hyracks.algebricks.common.utils.Pair)

Aggregations

IFunctionDescriptorFactory (org.apache.asterix.om.functions.IFunctionDescriptorFactory)5 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 IFunctionManager (org.apache.asterix.om.functions.IFunctionManager)1 FunctionManagerImpl (org.apache.asterix.runtime.evaluators.common.FunctionManagerImpl)1 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)1 Pair (org.apache.hyracks.algebricks.common.utils.Pair)1 FunctionIdentifier (org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier)1