Package com.foundationdb.server.types.texpressions

Examples of com.foundationdb.server.types.texpressions.TPreparedExpression


        }

        protected API.Ordering assembleSetOrdering(RowType rowType) {
            API.Ordering ordering = createOrdering();
            for (int i = 0; i < rowType.nFields(); i++) {
                TPreparedExpression tExpr = field(rowType, i);

                if(rowType.fieldHasColumn(i))
                    ordering.append(tExpr, true, rowType.fieldColumn(i).getCollator());
                else
                    ordering.append(tExpr, true, AkCollatorFactory.UCS_BINARY_COLLATOR );
View Full Code Here


        protected RowStream assembleSort(Sort sort,
                                         PlanNode output, API.SortOption sortOption) {
            RowStream stream = assembleStream(sort.getInput());
            API.Ordering ordering = createOrdering();
            for (OrderByExpression orderBy : sort.getOrderBy()) {
                TPreparedExpression tExpr = assembleExpression(orderBy.getExpression(),
                        stream.fieldOffsets);
                ordering.append(tExpr, orderBy.isAscending(), orderBy.getCollator());
            }
            assembleSort(stream, ordering, sort.getInput(), output, sortOption);
            return stream;
View Full Code Here

        protected void assembleSort(RowStream stream, int nkeys, PlanNode input,
                                    API.SortOption sortOption) {
            List<AkCollator> collators = findCollators(input);
            API.Ordering ordering = createOrdering();
            for (int i = 0; i < nkeys; i++) {
                TPreparedExpression tExpr = field(stream.rowType, i);
                ordering.append(tExpr, true,
                                (collators == null) ? null : collators.get(i));
            }
            assembleSort(stream, ordering, input, null, sortOption);
        }
View Full Code Here

        protected API.Ordering assembleIndexOrdering(IndexScan index,
                                                     IndexRowType indexRowType) {
            API.Ordering ordering = createOrdering();
            List<OrderByExpression> indexOrdering = index.getOrdering();
            for (int i = 0; i < indexOrdering.size(); i++) {
                TPreparedExpression tExpr = field(indexRowType, i);
                ordering.append(tExpr,
                                indexOrdering.get(i).isAscending(),
                                index.getIndexColumns().get(i).getColumn().getCollator());
            }
            return ordering;
View Full Code Here

        protected FullTextQueryExpression assembleFullTextQuery(FullTextQuery query,
                                                                FullTextQueryBuilder builder) {
            if (query instanceof FullTextField) {
                FullTextField field = (FullTextField)query;
                ExpressionNode key = field.getKey();
                TPreparedExpression expr = null;
                String constant = null;
                boolean isConstant = false;
                if (key.isConstant()) {
                    ValueSource valueSource = key.getPreptimeValue().value();
                    constant = (valueSource == null || valueSource.isNull()) ? null : valueSource.getString();
View Full Code Here

            return result;
        }

        public void assembleExpressionInto(ExpressionNode expr, ColumnExpressionToIndex fieldOffsets, TPreparedExpression[] arr,
                                           int i) {
            TPreparedExpression result = assembleExpression(expr, fieldOffsets);
            arr[i] = result;
        }
View Full Code Here

                else {
                    fieldExpression = true;
                }
            }
            RowStream stream = assembleQuery(subquery);
            TPreparedExpression innerExpression = null;
            if (fieldExpression)
                innerExpression = field(stream.rowType, 0);
            else if (expression != null)
                innerExpression = assembleExpression(expression, stream.fieldOffsets);
            TPreparedExpression result = assembleSubqueryExpression(sexpr,
                                                  stream.operator,
                                                  innerExpression,
                                                  outerRowType,
                                                  stream.rowType,
                                                  pos);
View Full Code Here

            else if (column.getDefaultFunction() != null) {
                OverloadResolver<TValidatedScalar> resolver = typesService.getScalarsResolver();
                TValidatedScalar overload = resolver.get(column.getDefaultFunction(),
                                                         Collections.<TPreptimeValue>emptyList()).getOverload();
                TInstance dinst = overload.resultStrategy().fixed(false);
                TPreparedExpression defExpr = new TPreparedFunction(overload,
                                                                    dinst,
                                                                    Collections.<TPreparedExpression>emptyList());
                if (!dinst.equals(type)) {
                    TCast tcast = typesService.getCastsResolver().cast(dinst.typeClass(), type.typeClass());
                    defExpr = new TCastExpression(defExpr, tcast, type);
View Full Code Here

    }

    public TPreparedExpression assembleExpression(ExpressionNode node,
                                                  ColumnExpressionContext columnContext,
                                                  SubqueryOperatorAssembler subqueryAssembler)  {
        TPreparedExpression possiblyLiteral = tryLiteral(node);
        if (possiblyLiteral != null)
            return possiblyLiteral;
        if (node instanceof ConstantExpression)
            return literal(((ConstantExpression)node));
        else if (node instanceof ColumnExpression)
            return assembleColumnExpression((ColumnExpression)node, columnContext);
        else if (node instanceof ParameterExpression)
            return variable((ParameterExpression)node);
        else if (node instanceof BooleanOperationExpression) {
            BooleanOperationExpression bexpr = (BooleanOperationExpression)node;
            return assembleFunction(bexpr, bexpr.getOperation().getFunctionName(),
                    Arrays.<ExpressionNode>asList(bexpr.getLeft(), bexpr.getRight()),
                    columnContext, subqueryAssembler);
        }
        else if (node instanceof CastExpression)
            return assembleCastExpression((CastExpression)node,
                    columnContext, subqueryAssembler);
        else if (node instanceof ComparisonCondition) {
            ComparisonCondition cond = (ComparisonCondition)node;
            TPreparedExpression left = assembleExpression(cond.getLeft(), columnContext, subqueryAssembler);
            TPreparedExpression right = assembleExpression(cond.getRight(), columnContext, subqueryAssembler);
            // never use a collator if we have a KeyComparable
            AkCollator collator = (cond.getKeyComparable() == null) ? collator(cond, left, right) : null;
            if (collator != null)
                return collate(left, cond.getOperation(), right, collator);
            else
                return compare(left, cond, right);
        }
        else if (node instanceof FunctionExpression) {
            FunctionExpression funcNode = (FunctionExpression)node;
            return assembleFunction(funcNode, funcNode.getFunction(),
                    funcNode.getOperands(),
                    columnContext, subqueryAssembler);
        }
        else if (node instanceof IfElseExpression) {
            IfElseExpression ifElse = (IfElseExpression)node;
            return assembleFunction(ifElse, "if",
                    Arrays.asList(ifElse.getTestCondition(),
                            ifElse.getThenExpression(),
                            ifElse.getElseExpression()),
                    columnContext, subqueryAssembler);
        }
        else if (node instanceof InListCondition) {
            InListCondition inList = (InListCondition)node;
            TPreparedExpression lhs = assembleExpression(inList.getOperand(),
                    columnContext, subqueryAssembler);
            List<TPreparedExpression> rhs = assembleExpressions(inList.getExpressions(),
                    columnContext, subqueryAssembler);
            return in(lhs, rhs, inList);
        }
View Full Code Here

    private TPreparedExpression assembleColumnExpression(ColumnExpression column,
                                                         ColumnExpressionContext columnContext) {
        if (column.getTable() instanceof CreateAs) {
            RowType rowType = columnContext.getRowType((CreateAs)column.getTable());
            TPreparedExpression expression = assembleBoundFieldExpression(rowType, OperatorAssembler.CREATE_AS_BINDING_POSITION, column.getPosition());
            if (explainContext != null)
                explainColumnExpression(expression, column);
            return expression;
        }
        ColumnExpressionToIndex currentRow = columnContext.getCurrentRow();
        if (currentRow != null) {
            int fieldIndex = currentRow.getIndex(column);
            if (fieldIndex >= 0) {
                TPreparedExpression expression = assembleFieldExpression(currentRow.getRowType(), fieldIndex);
                if (explainContext != null)
                    explainColumnExpression(expression, column);
                return expression;
            }
        }

        for (ColumnExpressionToIndex boundRow : columnContext.getBoundRows()) {
            int fieldIndex = boundRow.getIndex(column);
            if (fieldIndex >= 0) {
                int rowIndex = columnContext.getBindingPosition(boundRow);
                TPreparedExpression expression = assembleBoundFieldExpression(boundRow.getRowType(), rowIndex, fieldIndex);
                if (explainContext != null)
                    explainColumnExpression(expression, column);
                return expression;
            }
        }
        if(column.getTable() instanceof TableSource){

            RowType rowType = columnContext.getRowType(column.getColumn().getTable().getTableId());
            TPreparedExpression expression = assembleBoundFieldExpression(rowType, OperatorAssembler.CREATE_AS_BINDING_POSITION, column.getPosition());
            if (explainContext != null)
                explainColumnExpression(expression, column);
            return expression;
        }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.types.texpressions.TPreparedExpression

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.