Package com.foundationdb.sql.optimizer.rule

Examples of com.foundationdb.sql.optimizer.rule.PlanContext


        } catch (StandardException e) {
            throw new SQLParserInternalException(e);
        }
        StoreAdapter adapter = store().createAdapter(session, SchemaCache.globalSchema(ais));
        CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, false, ais);
        PlanContext plan = new PlanContext(compiler);
        ASTStatementLoader astStatementLoader = new ASTStatementLoader();
        AISBinder binder = new AISBinder(ais, table.getName().getSchemaName());
        try {
            binder.bind(stmt);
            BooleanNormalizer booleanNormalizer = new BooleanNormalizer(parser);
            stmt = booleanNormalizer.normalize(stmt);
            SubqueryFlattener subqueryFlattener = new SubqueryFlattener(parser);
            stmt = subqueryFlattener.flatten((DMLStatementNode)stmt);
        } catch (StandardException ex) {
            throw new SQLParserInternalException(ex);
        }
        plan.setPlan(new AST((DMLStatementNode)stmt, null));
        astStatementLoader.apply(plan);

        List<TableName> tableNames = new ArrayList<>();
        Deque<PlanNode> nodeQueue = new LinkedList<>();
        nodeQueue.add(plan.getPlan());
        while(!nodeQueue.isEmpty()){
            PlanNode node = nodeQueue.poll();
            if(node instanceof BasePlanWithInput){
                nodeQueue.add(((BasePlanWithInput)node).getInput());
            }
View Full Code Here


                                              String sql, StatementNode stmt,
                                              List<ParameterNode> params, int[] paramTypes) {
        setSchema(compiler.getSchema());
        DMLStatementNode dmlStmt = (DMLStatementNode)stmt;
        PostgresQueryContext queryContext = new PostgresQueryContext(server, this.schema);
        PlanContext planContext = new ServerPlanContext(compiler, queryContext);
        // TODO: This needs to make types with better default attributes or else
        // decimals and strings get truncated, collation doesn't match, etc.
        if (paramTypes != null && false) {
            for (ParameterNode param : params) {
                int paramno = param.getParameterNumber();
View Full Code Here

            DMLModStatementNode updateStmt = (DMLModStatementNode)sqlStmt;
            if (updateStmt.getReturningList() != null)
                throw JDBCException.wrapped("Statement already has RETURNING");
            addAutoGeneratedReturning(updateStmt, autoGeneratedKeys);
        }
        PlanContext planContext = new ServerPlanContext(this, context);
        BasePlannable result = compile(sqlStmt, sqlParams, planContext);
        Operator resultOperator = (Operator)result.getPlannable();
        JDBCResultSetMetaData resultSetMetaData = null;
        if (!result.isUpdate() || ((PhysicalUpdate)result).isReturning()) {
            List<ResultColumn> columns = new ArrayList<>();
View Full Code Here

        binder.setResultColumnsAvailableBroadly(Boolean.parseBoolean(getProperty("resultColumnsAvailableBroadly", "false")));
    }

    /** Compile a statement into an operator tree. */
    public BasePlannable compile(DMLStatementNode stmt, List<ParameterNode> params) {
        return compile(stmt, params, new PlanContext(this));
    }
View Full Code Here

            }
            AkibanInformationSchema onlineAIS = schemaManager.getOnlineAIS(session);
            StoreAdapter adapter = store.createAdapter(session, SchemaCache.globalSchema(onlineAIS));
            CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, false, onlineAIS);
            DMLStatementNode dmlStmt = (DMLStatementNode) stmt;
            PlanContext planContext = new PlanContext(compiler);

            BasePlannable result = compiler.compile(dmlStmt, null, planContext);

            Plannable plannable = result.getPlannable();
            QueryContext newContext = contextIfNull(context, adapter);
View Full Code Here

                } catch (StandardException e) {
                    throw new SQLParserInternalException(e);
                }
                StoreAdapter adapter = givenStore.createAdapter(session, SchemaCache.globalSchema(newAIS));
                CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, true, newAIS);
                PlanContext planContext = new PlanContext(compiler);
                BasePlannable insertResult = compiler.compile((DMLStatementNode) insertStmt, null, planContext);
                insertPlan = insertResult.getPlannable();
                deletePlan = new Delete_Returning(insertPlan.getInputOperators().iterator().next(), false);
            }
            int tableID = cs.getTableId();
View Full Code Here

        PlanNode plan = new AST((DMLStatementNode)stmt, parser.getParameterList());
        {
            RulesTestContext rulesContext =
                RulesTestContext.create(ais, null, false,
                                        Collections.<BaseRule>singletonList(new ASTStatementLoader()), new Properties());
            PlanContext planContext = new PlanContext(rulesContext, plan);
            rulesContext.applyRules(planContext);
            plan = planContext.getPlan();
        }
        PlanNode duplicate = (PlanNode)plan.duplicate();
        assertFalse(plan == duplicate);
        assertEqualsWithoutHashes(caseName,
                                  PlanToString.of(plan),
View Full Code Here

    public String generateResult() throws Exception {
        StatementNode stmt = parser.parseStatement(sql);
        binder.bind(stmt);
        stmt = booleanNormalizer.normalize(stmt);
        typeComputer.compute(stmt);
        PlanContext plan = new PlanContext(rules,
                                           new AST((DMLStatementNode)stmt,
                                                   parser.getParameterList()));
        rules.applyRules(plan);
        PlanNode node = plan.getPlan();
        Joinable joins = null;
        ConditionList whereConditions = null;
        while (true) {
            if (node instanceof Joinable) {
                joins = ((Joinable)node);
View Full Code Here

        binder.bind(stmt);
        stmt = booleanNormalizer.normalize(stmt);
        typeComputer.compute(stmt);
        stmt = subqueryFlattener.flatten((DMLStatementNode)stmt);
        // Turn parsed AST into intermediate form as starting point.
        PlanContext plan = new PlanContext(rules,
                new AST((DMLStatementNode)stmt,
                        parser.getParameterList()));
        rules.applyRules(plan);

        Map<Set<Map<String,Boolean>>,Integer> result = new HashMap<>();
        Collection<EquivalenceScope> scopes = new ColumnFinder().find(plan.getPlan());
        for (EquivalenceScope scope : scopes) {
            Collection<ColumnExpression> columnExpressions = scope.columns;
            int depth = scope.depth;
            Set<Map<String, Boolean>> byName = collectEquivalentColumns(columnExpressions, scope.equivs);
            Object old = result.put(byName, depth);
View Full Code Here

            case ELIMINATE_DISTINCTS:
                stmt = distinctEliminator.eliminate((DMLStatementNode)stmt);
                break;
            case PLAN:
                {
                    PlanContext plan =
                        new PlanContext(rulesContext,
                                        new AST((DMLStatementNode)stmt,
                                                parser.getParameterList()));
                    rulesContext.applyRules(plan);
                    System.out.println(PlanToString.of(plan.getPlan()));
                }
                break;
            case OPERATORS:
                {
                    Object compiled = operatorCompiler.compile((DMLStatementNode)stmt,
View Full Code Here

TOP

Related Classes of com.foundationdb.sql.optimizer.rule.PlanContext

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.