Package com.facebook.presto.metadata

Examples of com.facebook.presto.metadata.Signature


        return new Signature(IF, returnType.getName());
    }

    public static Signature nullIfSignature(Type returnType, Type firstType, Type secondType)
    {
        return new Signature(NULL_IF, returnType.getName(), firstType.getName(), secondType.getName());
    }
View Full Code Here


        return new Signature(NULL_IF, returnType.getName(), firstType.getName(), secondType.getName());
    }

    public static Signature switchSignature(Type returnType)
    {
        return new Signature(SWITCH, returnType.getName());
    }
View Full Code Here

        return new Signature(SWITCH, returnType.getName());
    }

    public static Signature whenSignature(Type returnType)
    {
        return new Signature("WHEN", returnType.getName());
    }
View Full Code Here

        @Override
        public RowExpression visitCall(CallExpression call, final Void context)
        {
            FunctionInfo function;
            Signature signature = call.getSignature();

            if (signature.getName().equals(CAST)) {
                if (call.getArguments().get(0).getType().equals(UnknownType.UNKNOWN)) {
                    return constantNull(call.getType());
                }
                function = registry.getCoercion(call.getArguments().get(0).getType(), call.getType());
            }
            else {
                switch (signature.getName()) {
                    // TODO: optimize these special forms
                    case IF:
                    case NULL_IF:
                    case SWITCH:
                    case TRY_CAST:
                    case IS_NULL:
                    case "IS_DISTINCT_FROM":
                    case COALESCE:
                    case "AND":
                    case "OR":
                    case IN:
                        return call;
                    default:
                        function = registry.getExactFunction(signature);
                        if (function == null) {
                            // TODO: temporary hack to deal with magic timestamp literal functions which don't have an "exact" form and need to be "resolved"
                            function = registry.resolveFunction(QualifiedName.of(signature.getName()), signature.getArgumentTypes(), false);
                        }
                }
            }

            List<RowExpression> arguments = Lists.transform(call.getArguments(), new Function<RowExpression, RowExpression>()
            {
                @Override
                public RowExpression apply(RowExpression input)
                {
                    return input.accept(Visitor.this, context);
                }
            });

            if (Iterables.all(arguments, instanceOf(ConstantExpression.class)) && function.isDeterministic()) {
                MethodHandle method = function.getMethodHandle();

                if (method.type().parameterCount() > 0 && method.type().parameterType(0) == ConnectorSession.class) {
                    method = method.bindTo(session);
                }

                List<Object> constantArguments = new ArrayList<>();
                for (RowExpression argument : arguments) {
                    Object value = ((ConstantExpression) argument).getValue();
                    // if any argument is null, return null
                    if (value == null) {
                        return constantNull(call.getType());
                    }
                    constantArguments.add(value);
                }

                try {
                    return constant(method.invokeWithArguments(constantArguments), call.getType());
                }
                catch (Throwable e) {
                    if (e instanceof InterruptedException) {
                        Thread.currentThread().interrupt();
                    }
                    throw Throwables.propagate(e);
                }
            }

            return call(signature, typeManager.getType(signature.getReturnType()), arguments);
        }
View Full Code Here

        protected RowExpression visitFunctionCall(FunctionCall node, Void context)
        {
            List<RowExpression> arguments = Lists.transform(node.getArguments(), processFunction(context));

            List<String> argumentTypes = Lists.transform(Lists.transform(arguments, typeGetter()), nameGetter());
            Signature signature = new Signature(node.getName().getSuffix(), types.get(node).getName(), argumentTypes);

            return call(signature, types.get(node), arguments);
        }
View Full Code Here

{
    private final Constructor<T> constructor;

    public ReflectionWindowFunctionSupplier(String name, Type returnType, List<? extends Type> argumentTypes, Class<T> type)
    {
        this(new Signature(name, returnType.getName(), Lists.transform(argumentTypes, nameGetter())), type);
    }
View Full Code Here

            ImmutableList.Builder<WindowFunction> windowFunctions = ImmutableList.builder();
            List<Symbol> windowFunctionOutputSymbols = new ArrayList<>();
            for (Map.Entry<Symbol, FunctionCall> entry : node.getWindowFunctions().entrySet()) {
                Symbol symbol = entry.getKey();
                Signature signature = node.getSignatures().get(symbol);
                windowFunctions.add(metadata.getFunction(signature).getWindowFunction().get());
                windowFunctionOutputSymbols.add(symbol);
            }

            // compute the layout of the output from the window operator
View Full Code Here

        return new FunctionCall(QualifiedName.of("test"), ImmutableList.<Expression>of());
    }

    private static Signature fakeFunctionHandle(String name)
    {
        return new Signature(name, UNKNOWN, ImmutableList.<Type>of(), false);
    }
View Full Code Here

{
    private final Constructor<T> constructor;

    public ReflectionWindowFunctionSupplier(String name, Type returnType, List<? extends Type> argumentTypes, Class<T> type)
    {
        this(new Signature(name, returnType, argumentTypes, false), type);
    }
View Full Code Here

            Map<Symbol, FunctionCall> finalCalls = new HashMap<>();
            Map<Symbol, FunctionCall> intermediateCalls = new HashMap<>();
            Map<Symbol, Signature> intermediateFunctions = new HashMap<>();
            Map<Symbol, Symbol> intermediateMask = new HashMap<>();
            for (Map.Entry<Symbol, FunctionCall> entry : aggregations.entrySet()) {
                Signature signature = functions.get(entry.getKey());
                FunctionInfo function = metadata.getExactFunction(signature);

                Symbol intermediateSymbol = allocator.newSymbol(function.getName().getSuffix(), function.getIntermediateType());
                intermediateCalls.put(intermediateSymbol, entry.getValue());
                intermediateFunctions.put(intermediateSymbol, signature);
View Full Code Here

TOP

Related Classes of com.facebook.presto.metadata.Signature

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.