Package com.facebook.presto.metadata

Examples of com.facebook.presto.metadata.OperatorInfo


            Type type = metadata.getType(node.getType());
            if (type == null) {
                throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType());
            }

            OperatorInfo operator;
            try {
                operator = metadata.getExactOperator(OperatorType.CAST, type, ImmutableList.of(VARCHAR));
            }
            catch (IllegalArgumentException e) {
                throw new SemanticException(TYPE_MISMATCH, node, "No literal form for type %s", type);
            }
            try {
                return ExpressionInterpreter.invoke(session, operator.getMethodHandle(), ImmutableList.<Object>of(utf8Slice(node.getValue())));
            }
            catch (Throwable throwable) {
                throw Throwables.propagate(throwable);
            }
        }
View Full Code Here


                String columnName = columnHandles.get(columnHandle);
                String value = null;
                if (entry.getValue() != null) {
                    ColumnMetadata columnMetadata  = metadata.getColumnMetadata(tableHandle.get(), columnHandle);
                    try {
                        OperatorInfo operator = metadata.getExactOperator(OperatorInfo.OperatorType.CAST, VarcharType.VARCHAR, ImmutableList.of(columnMetadata.getType()));
                        value = ((Slice) operator.getMethodHandle().invokeWithArguments(entry.getValue())).toStringUtf8();
                    }
                    catch (OperatorNotFoundException e) {
                        value = "<UNREPRESENTABLE VALUE>";
                    }
                    catch (Throwable throwable) {
View Full Code Here

        return functionBinding;
    }

    public FunctionBinding bindOperator(OperatorType operatorType, ByteCodeNode getSessionByteCode, List<ByteCodeNode> arguments, List<Type> argumentTypes)
    {
        OperatorInfo operatorInfo = metadata.resolveOperator(operatorType, argumentTypes);
        return bindOperator(operatorInfo, getSessionByteCode, arguments);
    }
View Full Code Here

        return bindOperator(operatorInfo, getSessionByteCode, arguments);
    }

    public FunctionBinding bindCastOperator(ByteCodeNode getSessionByteCode, ByteCodeNode sourceValue, Type sourceType, Type targetType)
    {
        OperatorInfo operatorInfo = metadata.getExactOperator(OperatorType.CAST, targetType, ImmutableList.of(sourceType));
        return bindOperator(operatorInfo, getSessionByteCode, ImmutableList.of(sourceValue));
    }
View Full Code Here

            if (type == null) {
                throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType());
            }

            try {
                OperatorInfo operator = metadata.getExactOperator(OperatorType.CAST, type, ImmutableList.of(VARCHAR));
                resolvedOperators.put(node, operator);
            }
            catch (IllegalArgumentException e) {
                throw new SemanticException(TYPE_MISMATCH, node, "No literal form for type %s", type);
            }
View Full Code Here

            }

            Type value = process(node.getExpression(), context);
            if (value != UNKNOWN) {
                try {
                    OperatorInfo operator = metadata.getExactOperator(OperatorType.CAST, type, ImmutableList.of(value));
                    resolvedOperators.put(node, operator);
                }
                catch (OperatorNotFoundException e) {
                    throw new SemanticException(TYPE_MISMATCH, node, "Cannot cast %s to %s", value, type);
                }
View Full Code Here

            ImmutableList.Builder<Type> argumentTypes = ImmutableList.builder();
            for (Expression expression : arguments) {
                argumentTypes.add(process(expression, context));
            }

            OperatorInfo operatorInfo;
            try {
                operatorInfo = metadata.resolveOperator(operatorType, argumentTypes.build());
            }
            catch (OperatorNotFoundException e) {
                throw new SemanticException(TYPE_MISMATCH, node, e.getMessage());
            }

            for (int i = 0; i < arguments.length; i++) {
                Expression expression = arguments[i];
                Type type = operatorInfo.getArgumentTypes().get(i);
                coerceType(context, expression, type, String.format("Operator %s argument %d", operatorInfo, i));
            }
            resolvedOperators.put(node, operatorInfo);

            expressionTypes.put(node, operatorInfo.getReturnType());

            return operatorInfo.getReturnType();
        }
View Full Code Here

            }
            if (value instanceof Expression) {
                return new NegativeExpression(toExpression(value, expressionTypes.get(node.getValue())));
            }

            OperatorInfo operatorInfo = metadata.resolveOperator(OperatorType.NEGATION, types(node.getValue()));

            MethodHandle handle = operatorInfo.getMethodHandle();
            if (handle.type().parameterCount() > 0 && handle.type().parameterType(0) == ConnectorSession.class) {
                handle = handle.bindTo(session);
            }
            try {
                return handle.invokeWithArguments(value);
View Full Code Here

            Type type = metadata.getType(node.getType());
            if (type == null) {
                throw new IllegalArgumentException("Unsupported type: " + node.getType());
            }

            OperatorInfo operatorInfo = metadata.getExactOperator(OperatorType.CAST, type, types(node.getExpression()));
            return invoke(session, operatorInfo.getMethodHandle(), ImmutableList.of(value));
        }
View Full Code Here

            return any(values, instanceOf(Expression.class));
        }

        private Object invokeOperator(OperatorType operatorType, List<? extends Type> argumentTypes, List<Object> argumentValues)
        {
            OperatorInfo operatorInfo = metadata.resolveOperator(operatorType, argumentTypes);
            return invoke(session, operatorInfo.getMethodHandle(), argumentValues);
        }
View Full Code Here

TOP

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

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.