Package com.facebook.presto.spi.type

Examples of com.facebook.presto.spi.type.Type


    }

    @Override
    protected ByteCodeNode visitIsNullPredicate(IsNullPredicate node, CompilerContext context)
    {
        Type valueType = expressionTypes.get(node.getValue());
        if (valueType.equals(UNKNOWN)) {
            return loadBoolean(true);
        }

        ByteCodeNode value = process(node.getValue(), context);

        // evaluate the expression, pop the produced value, and load the null flag
        Block block = new Block(context)
                .comment(node.toString())
                .append(value)
                .pop(valueType.getJavaType())
                .getVariable("wasNull");

        // clear the null flag
        block.putVariable("wasNull", false);
View Full Code Here


    }

    @Override
    protected ByteCodeNode visitSearchedCaseExpression(SearchedCaseExpression node, final CompilerContext context)
    {
        Type type = expressionTypes.get(node);
        ByteCodeNode elseValue;
        if (node.getDefaultValue() != null) {
            elseValue = process(node.getDefaultValue(), context);
        }
        else {
            elseValue = typedNull(context, type.getJavaType());
        }

        List<TypedWhenClause> whenClauses = ImmutableList.copyOf(transform(node.getWhenClauses(), new Function<WhenClause, TypedWhenClause>()
        {
            @Override
View Full Code Here

    @Override
    protected ByteCodeNode visitSimpleCaseExpression(SimpleCaseExpression node, final CompilerContext context)
    {
        // process value, else, and all when clauses
        ByteCodeNode value = process(node.getOperand(), context);
        Type type = expressionTypes.get(node);
        ByteCodeNode elseValue;
        if (node.getDefaultValue() != null) {
            elseValue = process(node.getDefaultValue(), context);
        }
        else {
            elseValue = typedNull(context, type.getJavaType());
        }

        List<TypedWhenClause> whenClauses = ImmutableList.copyOf(transform(node.getWhenClauses(), new Function<WhenClause, TypedWhenClause>()
        {
            @Override
View Full Code Here

    @Override
    protected ByteCodeNode visitNullIfExpression(NullIfExpression node, CompilerContext context)
    {
        ByteCodeNode first = process(node.getFirst(), context);
        ByteCodeNode second = process(node.getSecond(), context);
        Type firstType = expressionTypes.get(node.getFirst());
        Type secondType = expressionTypes.get(node.getSecond());

        LabelNode notMatch = new LabelNode("notMatch");

        // push first arg on the stack
        Block block = new Block(context)
                .comment(node.toString())
                .append(first)
                .append(ifWasNullPopAndGoto(context, notMatch, void.class));

        // this is a hack! We shouldn't be determining type coercions at this point, but there's no way
        // around it in the current expression AST
        Type commonType = FunctionRegistry.getCommonSuperType(firstType, secondType).get();

        FunctionBinding castFirst = bootstrapFunctionBinder.bindCastOperator(
                getSessionByteCode,
                new Block(context).dup(firstType.getJavaType()),
                firstType,
View Full Code Here

        for (Expression test : valueList.getValues()) {
            ByteCodeNode testNode = process(test, context);
            values.add(testNode);
        }

        Type type = expressionTypes.get(node.getValue());
        Class<?> javaType = type.getJavaType();

        FunctionBinding hashCodeFunction = bootstrapFunctionBinder.bindOperator(
                OperatorType.HASH_CODE,
                getSessionByteCode,
                ImmutableList.<ByteCodeNode>of(NOP),
View Full Code Here

        Block block = new Block(context)
                .comment("check if first arg is null")
                .append(generatorContext.generate(first))
                .append(ByteCodeUtils.ifWasNullPopAndGoto(context, notMatch, void.class));

        Type firstType = first.getType();
        Type secondType = second.getType();

        // this is a hack! We shouldn't be determining type coercions at this point, but there's no way
        // around it in the current expression AST
        Type commonType = FunctionRegistry.getCommonSuperType(firstType, secondType).get();

        FunctionBinding castFirst = generatorContext.getBootstrapBinder().bindCastOperator(
                generatorContext.generateGetSession(),
                new Block(context).dup(firstType.getJavaType()),
                firstType,
View Full Code Here

        CompilerContext context = generator.getContext();

        RowExpression left = arguments.get(0);
        RowExpression right = arguments.get(1);

        Type leftType = left.getType();
        Type rightType = right.getType();

        FunctionBinding functionBinding = generator.getBootstrapBinder().bindOperator(
                OperatorType.EQUAL,
                generator.generateGetSession(),
                ImmutableList.<ByteCodeNode>of(NOP, NOP),
                ImmutableList.of(leftType, rightType));

        ByteCodeNode equalsCall = new Block(context).comment("equals(%s, %s)", leftType, rightType)
                .invokeDynamic(functionBinding.getName(), functionBinding.getCallSite().type(), functionBinding.getBindingId());

        Block block = new Block(context)
                .comment("IS DISTINCT FROM")
                .comment("left")
                .append(generator.generate(left))
                .append(new IfStatement(context,
                        new Block(context).getVariable("wasNull"),
                        new Block(context)
                                .pop(leftType.getJavaType())
                                .putVariable("wasNull", false)
                                .comment("right is not null")
                                .append(generator.generate(right))
                                .pop(rightType.getJavaType())
                                .getVariable("wasNull")
                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class),
                        new Block(context)
                                .comment("right")
                                .append(generator.generate(right))
                                .append(new IfStatement(context,
                                        new Block(context).getVariable("wasNull"),
                                        new Block(context)
                                                .pop(leftType.getJavaType())
                                                .pop(rightType.getJavaType())
                                                .push(true),
                                        new Block(context)
                                                .append(equalsCall)
                                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class)))))
                .putVariable("wasNull", false);
View Full Code Here

                    if (value == null) {
                        row.add(null);
                        continue;
                    }

                    Type type = types.get(i);
                    if (BOOLEAN.equals(type)) {
                        row.add(value);
                    }
                    else if (BIGINT.equals(type)) {
                        row.add(((Number) value).longValue());
View Full Code Here

        {
            @Override
            public Type apply(Column column)
            {
                String typeName = column.getType();
                Type type = prestoServer.getMetadata().getType(typeName);
                if (type == null) {
                    throw new AssertionError("Unhandled type: " + typeName);
                }
                return type;
            }
View Full Code Here

        for (int i = 1; i < arguments.size(); i++) {
            ByteCodeNode testNode = generatorContext.generate(arguments.get(i));
            valuesByteCode.add(testNode);
        }

        Type type = arguments.get(0).getType();
        Class<?> javaType = type.getJavaType();

        FunctionBinding hashCodeFunction = generatorContext.getBootstrapBinder().bindOperator(
                OperatorType.HASH_CODE,
                generatorContext.generateGetSession(),
                ImmutableList.<ByteCodeNode>of(NOP),
View Full Code Here

TOP

Related Classes of com.facebook.presto.spi.type.Type

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.