Package com.facebook.presto.byteCode.control

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


        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


            // for huge IN lists, use a Set
            Binding constant = generatorContext.getCallSiteBinder().bind(constantValues, Set.class);

            switchBlock = new Block(context)
                    .comment("inListSet.contains(<stackValue>)")
                    .append(new IfStatement(context,
                            new Block(context)
                                    .comment("value (+boxing if necessary)")
                                    .dup(javaType)
                                    .append(ByteCodeUtils.boxPrimitive(context, javaType))
                                    .comment("set")
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

                .invokeInterface(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();

        return projectionType.getJavaType();
    }
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 {
            int field = input.getField();
            Block isNullCheck = new Block(context)
                    .setDescription(format("channel_%d.get%s(%d)", channel, type, field))
                    .getVariable("channel_" + channel)
                    .push(field)
                    .invokeInterface(TupleReadable.class, "isNull", boolean.class, int.class);

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

                    Block isNotNull = new Block(context)
                            .getVariable("channel_" + channel)
                            .push(field)
                            .invokeInterface(TupleReadable.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("channel_" + channel)
                            .push(field)
                            .invokeInterface(TupleReadable.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("channel_" + channel)
                            .push(field)
                            .invokeInterface(TupleReadable.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("channel_" + channel)
                            .push(field)
                            .invokeInterface(TupleReadable.class, "getSlice", Slice.class, int.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

                    .getVariable(tempVariable.getLocalVariableDefinition())
                    .invokeStatic(Operations.class, "equal", boolean.class, valueType, valueType)
                    .visitLabel(nullCondition)
                    .putVariable("wasNull", false);

            elseValue = typedByteCodeNode(new IfStatement(context,
                    format("when %s", whenClause),
                    condition,
                    coerceToType(context, whenClause.value, resultType).getNode(),
                    elseValue.getNode()), resultType);
        }
View Full Code Here

        Block trueBlock = new Block(context)
                .putVariable("wasNull", true)
                .pop(first.getType())
                .pushJavaDefault(first.getType());

        block.append(new IfStatement(context, conditionBlock, trueBlock, notMatch));

        return typedByteCodeNode(block, first.getType());
    }
View Full Code Here

TOP

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

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.