Package com.foundationdb.server.types.value

Examples of com.foundationdb.server.types.value.ValueSource


                        TCast constToCol = casts.cast(constType, columnType);
                        if (constToCol != null) {
                            TCast colToConst = casts.cast(columnType, constType);
                            if (colToConst != null) {
                                TPreptimeValue constValue = right.getPreptimeValue();
                                ValueSource asColType = castValue(constToCol, constValue, columnType);
                                TPreptimeValue asColTypeTpv = (asColType == null)
                                        ? null
                                        : new TPreptimeValue(columnType, asColType);
                                ValueSource backToConstType = castValue(colToConst, asColTypeTpv, constType);
                                if (ValueSources.areEqual(constValue.value(), backToConstType)) {
                                    TPreptimeValue constTpv = new TPreptimeValue(columnType, asColType);
                                    ConstantExpression constCasted = new ConstantExpression(constTpv);
                                    expression.setRight(constCasted);
                                    assert columnType.equals(type(expression.getRight()));
View Full Code Here


        return result;
    }

    private static ExpressionNode boolExpr(ExpressionNode expression, boolean nullable) {
        TInstance type = AkBool.INSTANCE.instance(nullable);
        ValueSource value = null;
        if (expression.getPreptimeValue() != null) {
            if (type.equals(expression.getPreptimeValue().type()))
                return expression;
            value = expression.getPreptimeValue().value();
        }
View Full Code Here

            castExpression.setPreptimeValue(new TPreptimeValue(targetInstance));
            parametersSync.set(expression, targetInstance);
            return castExpression;
        }
        if (expression instanceof NullSource) {
            ValueSource nullSource = ValueSources.getNullSource(targetInstance);
            expression.setPreptimeValue(new TPreptimeValue(targetInstance, nullSource));
            return expression;
        }

        if (equalForCast(targetInstance, type(expression)))
View Full Code Here

    {
        return node.isConstant();
    }

    protected boolean encodeKeyValue(ExpressionNode node, Index index, int column) {
        ValueSource value = null;
        if (node instanceof ConstantExpression) {
            if (node.getPreptimeValue() != null) {
                if (node.getType() == null) { // Literal null
                    keyPTarget.putNull();
                    return true;
View Full Code Here

        Row row = cursor.next();
        // Get and checking each field should work
        assertEquals(11, row.value(0).getInt32());
        assertEquals(111, row.value(1).getInt32());
        // Getting all value sources and then using them should also work
        ValueSource v0 = row.value(0);
        ValueSource v1 = row.value(1);
        assertEquals(11, v0.getInt32());
        assertEquals(111, v1.getInt32());
    }
View Full Code Here

        {
            // if either is not constant, preptime values aren't available
            if (!leftNode.isConstant() || !rightNode.isConstant())
                return false;
           
            ValueSource leftSource = leftNode.getPreptimeValue().value();
            ValueSource rightSource = rightNode.getPreptimeValue().value();

            TInstance lTIns = leftSource.getType();
            TInstance rTIns = rightSource.getType();
           
            if (TClass.comparisonNeedsCasting(lTIns, rTIns))
            {
                boolean nullable = leftSource.isNull() || rightSource.isNull();
                TCastResolver casts = registry.getCastsResolver();
                TInstance common = TypeResolver.commonInstance(casts, lTIns, rTIns);
                if (common == null)
                    common = typesTranslator.typeForString();
               
View Full Code Here

                    ? fun
                    : new ConstantExpression(preptimeValue);
        }

        protected Boolean getBooleanObject(ConstantExpression expression) {
            ValueSource value = expression.getPreptimeValue().value();
            return value == null || value.isNull()
                    ? null
                    : value.getBoolean();
        }
View Full Code Here

                    : value.getBoolean();
        }

        protected Constantness isConstant(ExpressionNode expr) {
            TPreptimeValue tpv = expr.getPreptimeValue();
            ValueSource value = tpv.value();
            if (tpv.type() == null) {
                assert value == null || value.isNull() : value;
                assert !(expr instanceof ParameterExpression) : value;
                return Constantness.NULL;
            }
            if (value == null)
                return Constantness.VARIABLE;
            return value.isNull()
                    ? Constantness.NULL
                    : Constantness.CONSTANT;
        }
View Full Code Here

    private TPreparedExpression tryLiteral(ExpressionNode node) {
        TPreparedExpression result = null;
        TPreptimeValue tpv = node.getPreptimeValue();
        if (tpv != null) {
            TInstance type = tpv.type();
            ValueSource value = tpv.value();
            if (type != null && value != null)
                result = new TPreparedLiteral(type, value);
        }
        return result;
    }
View Full Code Here

            return (ConstantExpression)node;
        TPreparedExpression expr = assembleExpression(node, null, null);
        TPreptimeValue preptimeValue = expr.evaluateConstant(planContext.getQueryContext());
        if (preptimeValue == null)
            throw new AkibanInternalException("required constant expression: " + expr);
        ValueSource valueSource = preptimeValue.value();
        if (valueSource == null)
            throw new AkibanInternalException("required constant expression: " + expr);
        if (node instanceof ConditionExpression) {
            Boolean value = valueSource.isNull() ? null : valueSource.getBoolean();
            return new BooleanConstantExpression(value);
        }
        else {
            return new ConstantExpression(preptimeValue);
        }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.value.ValueSource

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.