Examples of TPreptimeValue


Examples of com.foundationdb.server.types.TPreptimeValue

        public void updateTypes(TypesTranslator typesTranslator) {
            int nparams = instancesMap.lastDefinedIndex();
            for (int i = 0; i < nparams; i++) {
                if (!instancesMap.isDefined(i)) continue;
                List<ExpressionNode> siblings = instancesMap.get(i);
                TPreptimeValue sharedTpv = siblings.get(0).getPreptimeValue();
                TInstance type = sharedTpv.type();
                DataTypeDescriptor sqlType = null;
                if (type == null) {
                    sqlType = siblings.get(0).getSQLtype();
                    if (sqlType != null)
                        type = typesTranslator.typeForSQLType(sqlType);
                    else
                        type = typesTranslator.typeClassForString().instance(true);
                    sharedTpv.type(type);
                }
                if (sqlType == null)
                    sqlType = type.dataTypeDescriptor();
                for (ExpressionNode param : siblings) {
                    param.setSQLtype(sqlType);
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        if (expression.getPreptimeValue() != null) {
            if (type.equals(expression.getPreptimeValue().type()))
                return expression;
            value = expression.getPreptimeValue().value();
        }
        expression.setPreptimeValue(new TPreptimeValue(type, value));
        return expression;
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        // parameters and literal nulls have no type, so just set the type -- they'll be polymorphic about it.
        if (expression instanceof ParameterExpression) {
            targetInstance = targetInstance.withNullable(true);
            CastExpression castExpression =
                newCastExpression(expression, targetInstance);
            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)))
            return expression;
        DataTypeDescriptor sqlType = expression.getSQLtype();
        targetInstance = targetInstance.withNullable(sqlType == null || sqlType.isNullable());
        CastExpression castExpression =
            newCastExpression(expression, targetInstance);
        castExpression.setPreptimeValue(new TPreptimeValue(targetInstance));
        ExpressionNode result = finishCast(castExpression, folder, parametersSync);
        result = folder.foldConstants(result);
        return result;
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

    private static TClass tclass(TInstance type) {
        return (type == null) ? null : type.typeClass();
    }

    private static TInstance type(ExpressionNode node) {
        TPreptimeValue ptv = node.getPreptimeValue();
        return ptv == null ? null : ptv.type();
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

                        source.getSQLsource(),
                        source.getType()));
        }

        protected ExpressionNode genericFunctionExpression(FunctionExpression fun) {
            TPreptimeValue preptimeValue = fun.getPreptimeValue();
            return (preptimeValue.value() == null)
                    ? fun
                    : new ConstantExpression(preptimeValue);
        }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

                    ? null
                    : 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)
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        return expr;
    }

    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

Examples of com.foundationdb.server.types.TPreptimeValue

        }
        return result;
    }

    private TPreparedExpression literal(ConstantExpression expression) {
        TPreptimeValue ptval = expression.getPreptimeValue();
        return new TPreparedLiteral(ptval.type(), ptval.value());
    }
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

    public ConstantExpression evalNow(PlanContext planContext, ExpressionNode node) {
        if (node instanceof ConstantExpression)
            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);
View Full Code Here

Examples of com.foundationdb.server.types.TPreptimeValue

        // Build UPDATE-replacing project
        TPreparedExpression field0 = ExpressionGenerators.field(itemRowType, 0).getTPreparedExpression();
        TPreparedExpression field1 = ExpressionGenerators.field(itemRowType, 1).getTPreparedExpression();
        TPreparedExpression literal = ExpressionGenerators.literal(1000).getTPreparedExpression();
        TValidatedScalar plus = typesRegistryService().getScalarsResolver().get(
            "plus", asList(new TPreptimeValue(field0.resultType()), new TPreptimeValue(literal.resultType()))
        ).getOverload();
        TPreparedFunction prepFunc = new TPreparedFunction(
            plus, plus.resultType().fixed(false), Arrays.asList(field0, literal)
        );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.