Package com.facebook.presto.byteCode.control

Examples of com.facebook.presto.byteCode.control.IfStatement


        if (!stackArgsToPop.isEmpty()) {
            popComment = format("pop(%s)", Joiner.on(", ").join(stackArgsToPop));
        }

        String comment = format("if wasNull then %s", Joiner.on(", ").skipNulls().join(clearComment, popComment, loadDefaultComment, "goto " + label.getLabel()));
        return new IfStatement(context, comment, nullCheck, isNull, NOP);
    }
View Full Code Here


                    .invokeVirtual(BlockBuilder.class, "appendNull", BlockBuilder.class)
                    .pop();

            projectionMethod.getBody()
                    .comment("if the result was null, appendNull; otherwise append the value")
                    .append(new IfStatement(context, new Block(context).getVariable("wasNull"), nullBlock, notNullBlock))
                    .ret();
        }
        else {
            projectionMethod
                    .getBody()
View Full Code Here

        classDefinition.declareMethod(context,
                a(PUBLIC),
                "getCurrentJoinPosition",
                type(long.class))
                .getBody()
                .append(new IfStatement(
                        context,
                        new Block(context).append(context.getVariable("this").invoke("currentRowContainsNull", boolean.class)),
                        new Block(context).push(-1L).retLong(),
                        null
                ))
View Full Code Here

                        .push(field);

                String methodName = "get" + Primitives.wrap(javaType).getSimpleName();
                isNotNull.invokeInterface(RecordCursor.class, methodName, javaType, int.class);

                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }

            @Override
            public ByteCodeNode visitCall(CallExpression call, CompilerContext context)
            {
View Full Code Here

                        .append(loadConstant(context, callSiteBinder.bind(type, Type.class)))
                        .getVariable("block_" + field)
                        .getVariable(positionVariable)
                        .invokeInterface(Type.class, methodName, javaType, com.facebook.presto.spi.block.Block.class, int.class);

                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }

            @Override
            public ByteCodeNode visitCall(CallExpression call, CompilerContext context)
            {
View Full Code Here

        if (!stackArgsToPop.isEmpty()) {
            popComment = format("pop(%s)", Joiner.on(", ").join(stackArgsToPop));
        }

        String comment = format("if wasNull then %s", Joiner.on(", ").skipNulls().join(clearComment, popComment, loadDefaultComment, "goto " + label.getLabel()));
        return new IfStatement(context, comment, nullCheck, isNull, NOP);
    }
View Full Code Here

                    .invokeVirtual(BlockBuilder.class, "appendNull", BlockBuilder.class)
                    .pop();

            projectionMethod.getBody()
                    .comment("if the result was null, appendNull; otherwise append the value")
                    .append(new IfStatement(context, new Block(context).getVariable("wasNull"), nullBlock, notNullBlock))
                    .ret();
        }
        else {
            projectionMethod
                    .getBody()
View Full Code Here

                    Block isNotNull = new Block(context)
                            .getVariable("cursor")
                            .push(channel)
                            .invokeInterface(RecordCursor.class, "getBoolean", boolean.class, int.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), boolean.class);
                }
                case BIGINT: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(long.class);

                    Block isNotNull = new Block(context)
                            .getVariable("cursor")
                            .push(channel)
                            .invokeInterface(RecordCursor.class, "getLong", long.class, int.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), long.class);
                }
                case DOUBLE: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(double.class);

                    Block isNotNull = new Block(context)
                            .getVariable("cursor")
                            .push(channel)
                            .invokeInterface(RecordCursor.class, "getDouble", double.class, int.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), double.class);
                }
                case VARCHAR: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(Slice.class);

                    Block isNotNull = new Block(context)
                            .getVariable("cursor")
                            .push(channel)
                            .invokeInterface(RecordCursor.class, "getString", byte[].class, int.class)
                            .invokeStatic(Slices.class, "wrappedBuffer", Slice.class, byte[].class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), Slice.class);
                }
                default:
                    throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
        else {
            Block isNullCheck = new Block(context)
                    .setDescription(format("channel_%d.get%s()", channel, type))
                    .getVariable("channel_" + channel)
                    .invokeInterface(TupleReadable.class, "isNull", boolean.class);

            switch (type) {
                case BOOLEAN: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(boolean.class);

                    Block isNotNull = new Block(context)
                            .getVariable("channel_" + channel)
                            .invokeInterface(TupleReadable.class, "getBoolean", boolean.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), boolean.class);
                }
                case BIGINT: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(long.class);

                    Block isNotNull = new Block(context)
                            .getVariable("channel_" + channel)
                            .invokeInterface(TupleReadable.class, "getLong", long.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), long.class);
                }
                case DOUBLE: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(double.class);

                    Block isNotNull = new Block(context)
                            .getVariable("channel_" + channel)
                            .invokeInterface(TupleReadable.class, "getDouble", double.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), double.class);
                }
                case VARCHAR: {
                    Block isNull = new Block(context)
                            .putVariable("wasNull", true)
                            .pushJavaDefault(Slice.class);

                    Block isNotNull = new Block(context)
                            .getVariable("channel_" + channel)
                            .invokeInterface(TupleReadable.class, "getSlice", Slice.class);

                    return typedByteCodeNode(new IfStatement(context, isNullCheck, isNull, isNotNull), Slice.class);
                }
                default:
                    throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
View Full Code Here

        }

        trueValue = coerceToType(context, trueValue, type);
        falseValue = coerceToType(context, falseValue, type);

        return typedByteCodeNode(new IfStatement(context, condition, trueValue.getNode(), falseValue.getNode()), type);
    }
View Full Code Here

                    .getVariable("wasNull")
                    .invokeStatic(Operations.class, "not", boolean.class, boolean.class)
                    .invokeStatic(Operations.class, "and", boolean.class, boolean.class, boolean.class)
                    .putVariable("wasNull", false);

            elseValue = typedByteCodeNode(new IfStatement(context, condition, coerceToType(context, whenClause.value, type).getNode(), elseValue.getNode()), type);
        }

        return elseValue;
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.byteCode.control.IfStatement

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.