Package com.foundationdb.server.types

Examples of com.foundationdb.server.types.TPreptimeValue


            elseExpr = castTo(elseExpr, commonInstance, folder, parametersSync);

            expression.setThenExpression(thenExpr);
            expression.setElseExpression(elseExpr);

            expression.setPreptimeValue(new TPreptimeValue(commonInstance));
            return expression;
        }
View Full Code Here


            return boolExpr(expression, true);
        }

        ExpressionNode handleSubqueryValueExpression(SubqueryValueExpression expression) {
            TypedPlan typedSubquery = findTypedPlanNode(expression.getSubquery().getInput());
            TPreptimeValue tpv;
            assert typedSubquery.nFields() == 1 : typedSubquery;
            if (typedSubquery instanceof Project) {
                Project project = (Project) typedSubquery;
                List<ExpressionNode> projectFields = project.getFields();
                assert projectFields.size() == 1 : projectFields;
                tpv = projectFields.get(0).getPreptimeValue();
            }
            else {
                tpv = new TPreptimeValue(typedSubquery.getTypeAt(0));
            }
            expression.setPreptimeValue(tpv);
            return expression;
        }
View Full Code Here

        ExpressionNode handleSubqueryResultSetExpression(SubqueryResultSetExpression expression) {
            DataTypeDescriptor sqlType = expression.getSQLtype();
            if (sqlType.isRowMultiSet()) {
                setMissingRowMultiSetColumnTypes(sqlType, expression.getSubquery());
            }
            TPreptimeValue tpv = new TPreptimeValue(typesTranslator.typeForSQLType(sqlType));
            expression.setPreptimeValue(tpv);
            return expression;
        }
View Full Code Here

                        TInstance constType = type(right);
                        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()));
                                    needCasts = false;
                                }
View Full Code Here

                    (expression.getSQLtype() != null) &&
                    (expression.getSQLtype().isNullable())) {
                    // With an outer join, the column can still be nullable.
                    columnInstance = columnInstance.withNullable(true);
                }
                expression.setPreptimeValue(new TPreptimeValue(columnInstance));
            }
            else if (columnSource instanceof AggregateSource) {
                AggregateSource aggTable = (AggregateSource) columnSource;
                TPreptimeValue ptv = aggTable.getField(expression.getPosition()).getPreptimeValue();
                expression.setPreptimeValue(ptv);
            }
            else if (columnSource instanceof SubquerySource) {
                TPreptimeValue tpv;
                Subquery subquery = ((SubquerySource)columnSource).getSubquery();
                TypedPlan typedSubquery = findTypedPlanNode(subquery.getInput());
                if (typedSubquery != null) {
                    tpv = new TPreptimeValue(typedSubquery.getTypeAt(expression.getPosition()));
                }
                else {
                    logger.warn("no Project found for subquery: {}", columnSource);
                    tpv = new TPreptimeValue(typesTranslator.typeForSQLType(expression.getSQLtype()));
                }
                expression.setPreptimeValue(tpv);
                return expression;
            }
            else if (columnSource instanceof NullSource) {
                expression.setPreptimeValue(new TPreptimeValue(null, null));
                return expression;
            }
            else if (columnSource instanceof Project) {
                Project pTable = (Project) columnSource;
                TPreptimeValue ptv = pTable.getFields().get(expression.getPosition()).getPreptimeValue();
                expression.setPreptimeValue(ptv);
            }
            else if (columnSource instanceof ExpressionsSource) {
                ExpressionsSource exprsTable = (ExpressionsSource) columnSource;
                List<List<ExpressionNode>> expressions = exprsTable.getExpressions();
                TPreptimeValue tpv;
                if (expressions.size() == 1) {
                    // get the TPV straight from the expression, since there's just one row
                    tpv = expressions.get(0).get(expression.getPosition()).getPreptimeValue();
                }
                else {
                    TInstance type = exprsTable.getTypeAt(expression.getPosition());
                    tpv = new TPreptimeValue(type);
                }
                expression.setPreptimeValue(tpv);
            }
            else if (columnSource instanceof CreateAs){
                expression.setPreptimeValue(new TPreptimeValue(null, null));
                return expression;
            }
            else {
                throw new AssertionError(columnSource + "(" + columnSource.getClass() + ")");
            }
View Full Code Here

            for (int i = 0; i < operands.size(); i++) {
                ExpressionNode operand = castTo(operands.get(i), routine.getParameters().get(i).getType(),
                                                folder, parametersSync);
                operands.set(i, operand);
            }
            TPreptimeValue tpv = new TPreptimeValue(routine.getReturnValue().getType());
            expression.setPreptimeValue(tpv);
            return expression;
        }
View Full Code Here

            return expression;
        }

        ExpressionNode handleColumnDefaultExpression(ColumnDefaultExpression expression) {
            if (expression.getPreptimeValue() == null) {
                TPreptimeValue tpv = new TPreptimeValue(expression.getColumn().getType());
                expression.setPreptimeValue(tpv);
            }
            return expression;
        }
View Full Code Here


        private void castProjectField (CastExpression cast, Folder folder, ParametersSync parameterSync, TypesTranslator typesTranslator) {
            DataTypeDescriptor dtd = cast.getSQLtype();
            TInstance type = typesTranslator.typeForSQLType(dtd);
            cast.setPreptimeValue(new TPreptimeValue(type));
            TypeResolver.finishCast(cast, folder, parameterSync);
        }
View Full Code Here

            this.instancesMap = new SparseArray<>();
        }

        public void uninferred(ParameterExpression parameterExpression) {
            //assert parameterExpression.getPreptimeValue() == null : parameterExpression;
            TPreptimeValue preptimeValue;
            List<ExpressionNode> siblings = siblings(parameterExpression);
            if (siblings.isEmpty()) {
                preptimeValue = new TPreptimeValue();
                if (parameterExpression.getSQLsource() != null)
                    // Start with type client intends to send, if any.
                    preptimeValue.type((TInstance) parameterExpression.getSQLsource().getUserData());
                parameterExpression.setPreptimeValue(new TPreptimeValue());
            }
            else {
                preptimeValue = siblings.get(0).getPreptimeValue();
            }
            parameterExpression.setPreptimeValue(preptimeValue);
View Full Code Here

            return siblings;
        }

        public void set(ExpressionNode node, TInstance type) {
            List<ExpressionNode> siblings = siblings((ParameterExpression) node);
            TPreptimeValue sharedTpv = siblings.get(0).getPreptimeValue();
            TInstance previousInstance = sharedTpv.type();
            type = commonInstance(resolver, type, previousInstance);
            sharedTpv.type(type);
        }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.TPreptimeValue

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.