Package com.facebook.presto.operator.scalar

Examples of com.facebook.presto.operator.scalar.ScalarFunction


        public FunctionListBuilder scalar(Class<?> clazz)
        {
            try {
                boolean foundOne = false;
                for (Method method : clazz.getMethods()) {
                    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
                    if (scalarFunction == null) {
                        continue;
                    }
                    checkValidMethod(method);
                    MethodHandle methodHandle = lookup().unreflect(method);
                    String name = scalarFunction.value();
                    if (name.isEmpty()) {
                        name = camelToSnake(method.getName());
                    }
                    String description = getDescription(method);
                    FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction);
                    scalar(name, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    for (String alias : scalarFunction.alias()) {
                        scalar(alias, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    }
                    foundOne = true;
                }
                checkArgument(foundOne, "Expected class %s to contain at least one method annotated with @%s", clazz.getName(), ScalarFunction.class.getSimpleName());
            }
View Full Code Here


        public FunctionListBuilder scalar(Class<?> clazz)
        {
            try {
                boolean foundOne = false;
                for (Method method : clazz.getMethods()) {
                    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
                    if (scalarFunction == null) {
                        continue;
                    }
                    checkValidMethod(method);
                    MethodHandle methodHandle = lookup().unreflect(method);
                    String name = scalarFunction.value();
                    if (name.isEmpty()) {
                        name = camelToSnake(method.getName());
                    }
                    String description = getDescription(method);
                    FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction);
                    scalar(name, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    for (String alias : scalarFunction.alias()) {
                        scalar(alias, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    }
                    foundOne = true;
                }
                checkArgument(foundOne, "Expected class %s to contain at least one method annotated with @%s", clazz.getName(), ScalarFunction.class.getSimpleName());
            }
View Full Code Here

        public FunctionListBuilder scalar(Class<?> clazz)
        {
            try {
                boolean foundOne = false;
                for (Method method : clazz.getMethods()) {
                    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
                    if (scalarFunction == null) {
                        continue;
                    }
                    checkValidMethod(method);
                    MethodHandle methodHandle = lookup().unreflect(method);
                    String name = scalarFunction.value();
                    if (name.isEmpty()) {
                        name = camelToSnake(method.getName());
                    }
                    String description = getDescription(method);
                    FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction);
                    scalar(name, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    for (String alias : scalarFunction.alias()) {
                        scalar(alias, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    }
                    foundOne = true;
                }
                checkArgument(foundOne, "Expected class %s to contain at least one method annotated with @%s", clazz.getName(), ScalarFunction.class.getSimpleName());
            }
View Full Code Here

        }

        private boolean processScalarFunction(Method method)
                throws IllegalAccessException
        {
            ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
            if (scalarFunction == null) {
                return false;
            }
            checkValidMethod(method);
            MethodHandle methodHandle = lookup().unreflect(method);
            String name = scalarFunction.value();
            if (name.isEmpty()) {
                name = camelToSnake(method.getName());
            }
            SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
            checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
            Type returnType = type(returnTypeAnnotation);
            Signature signature = new Signature(name.toLowerCase(), returnType, parameterTypes(method), false, false);

            verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes());

            FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction.functionBinder());

            scalar(signature, methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            for (String alias : scalarFunction.alias()) {
                scalar(signature.withAlias(alias.toLowerCase()), methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            }
            return true;
        }
View Full Code Here

        public FunctionListBuilder scalar(Class<?> clazz)
        {
            try {
                boolean foundOne = false;
                for (Method method : clazz.getMethods()) {
                    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
                    if (scalarFunction == null) {
                        continue;
                    }
                    checkValidMethod(method);
                    MethodHandle methodHandle = lookup().unreflect(method);
                    String name = scalarFunction.value();
                    if (name.isEmpty()) {
                        name = camelToSnake(method.getName());
                    }
                    String description = getDescription(method);
                    FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction);
                    scalar(name, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    for (String alias : scalarFunction.alias()) {
                        scalar(alias, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    }
                    foundOne = true;
                }
                checkArgument(foundOne, "Expected class %s to contain at least one method annotated with @%s", clazz.getName(), ScalarFunction.class.getSimpleName());
            }
View Full Code Here

        }

        private boolean processScalarFunction(Method method)
                throws IllegalAccessException
        {
            ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
            if (scalarFunction == null) {
                return false;
            }
            checkValidMethod(method);
            MethodHandle methodHandle = lookup().unreflect(method);
            String name = scalarFunction.value();
            if (name.isEmpty()) {
                name = camelToSnake(method.getName());
            }
            SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
            checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
            Type returnType = type(returnTypeAnnotation);
            Signature signature = new Signature(name.toLowerCase(), returnType, parameterTypes(method), false);

            verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes());

            FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction.functionBinder());

            scalar(signature, methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            for (String alias : scalarFunction.alias()) {
                scalar(signature.withAlias(alias.toLowerCase()), methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            }
            return true;
        }
View Full Code Here

        }

        private boolean processScalarFunction(Method method)
                throws IllegalAccessException
        {
            ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
            if (scalarFunction == null) {
                return false;
            }
            checkValidMethod(method);
            MethodHandle methodHandle = lookup().unreflect(method);
            String name = scalarFunction.value();
            if (name.isEmpty()) {
                name = camelToSnake(method.getName());
            }
            SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
            checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
            Type returnType = type(returnTypeAnnotation);
            Signature signature = new Signature(name.toLowerCase(), returnType, parameterTypes(method), false);

            verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes());

            FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction.functionBinder());

            scalar(signature, methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            for (String alias : scalarFunction.alias()) {
                scalar(signature.withAlias(alias.toLowerCase()), methodHandle, scalarFunction.deterministic(), functionBinder, getDescription(method), scalarFunction.hidden());
            }
            return true;
        }
View Full Code Here

        }

        private boolean processScalarFunction(Method method)
                throws IllegalAccessException
        {
            ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
            if (scalarFunction == null) {
                return false;
            }
            checkValidMethod(method);
            MethodHandle methodHandle = lookup().unreflect(method);
            String name = scalarFunction.value();
            if (name.isEmpty()) {
                name = camelToSnake(method.getName());
            }
            SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
            checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
            Type returnType = type(returnTypeAnnotation);
            Signature signature = new Signature(name.toLowerCase(), returnType, parameterTypes(method));

            verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes());

            scalar(signature, methodHandle, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class));
            for (String alias : scalarFunction.alias()) {
                scalar(signature.withAlias(alias.toLowerCase()), methodHandle, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class));
            }
            return true;
        }
View Full Code Here

    }

    private boolean processScalarFunction(Method method)
            throws IllegalAccessException
    {
        ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
        if (scalarFunction == null) {
            return false;
        }
        checkValidMethod(method);
        MethodHandle methodHandle = lookup().unreflect(method);
        String name = scalarFunction.value();
        if (name.isEmpty()) {
            name = camelToSnake(method.getName());
        }
        SqlType returnTypeAnnotation = method.getAnnotation(SqlType.class);
        checkArgument(returnTypeAnnotation != null, "Method %s return type does not have a @SqlType annotation", method);
        Type returnType = type(typeManager, returnTypeAnnotation);
        Signature signature = new Signature(name.toLowerCase(), returnType.getName(), Lists.transform(parameterTypes(typeManager, method), nameGetter()));

        verifyMethodSignature(method, signature.getReturnType(), signature.getArgumentTypes(), typeManager);

        List<Boolean> nullableArguments = getNullableArguments(method);

        scalar(signature, methodHandle, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class), nullableArguments);
        for (String alias : scalarFunction.alias()) {
            scalar(signature.withAlias(alias.toLowerCase()), methodHandle, scalarFunction.deterministic(), getDescription(method), scalarFunction.hidden(), method.isAnnotationPresent(Nullable.class), nullableArguments);
        }
        return true;
    }
View Full Code Here

        public FunctionListBuilder scalar(Class<?> clazz)
        {
            try {
                boolean foundOne = false;
                for (Method method : clazz.getMethods()) {
                    ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
                    if (scalarFunction == null) {
                        continue;
                    }
                    checkValidMethod(method);
                    MethodHandle methodHandle = lookup().unreflect(method);
                    String name = scalarFunction.value();
                    if (name.isEmpty()) {
                        name = camelToSnake(method.getName());
                    }
                    String description = getDescription(method);
                    FunctionBinder functionBinder = createFunctionBinder(method, scalarFunction);
                    scalar(name, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    for (String alias : scalarFunction.alias()) {
                        scalar(alias, methodHandle, scalarFunction.deterministic(), functionBinder, description);
                    }
                    foundOne = true;
                }
                checkArgument(foundOne, "Expected class %s to contain at least one method annotated with @%s", clazz.getName(), ScalarFunction.class.getSimpleName());
            }
View Full Code Here

TOP

Related Classes of com.facebook.presto.operator.scalar.ScalarFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.