Package org.voltdb

Examples of org.voltdb.SQLStmt


        // determine if proc is read or read-write by checking if the proc contains any write sql stmts
        boolean readWrite = false;
        for (Object field : fields.values()) {
            if (!(field instanceof SQLStmt)) continue;
            SQLStmt stmt = (SQLStmt)field;
            QueryType qtype = QueryType.getFromSQL(stmt.getText());
            if (!qtype.isReadOnly()) {
                readWrite = true;
                break;
            }
        }

        // default to FASTER determinism mode, which may favor non-deterministic plans
        // but if it's a read-write proc, use a SAFER planning mode wrt determinism.
        final DeterminismMode detMode = readWrite ? DeterminismMode.SAFER : DeterminismMode.FASTER;

        for (Entry<String, Object> entry : fields.entrySet()) {
            if (!(entry.getValue() instanceof SQLStmt)) continue;

            String stmtName = entry.getKey();
            SQLStmt stmt = (SQLStmt)entry.getValue();

            // add the statement to the catalog
            Statement catalogStmt = procedure.getStatements().add(stmtName);

            // compile the statement
            StatementPartitioning partitioning =
                info.singlePartition ? StatementPartitioning.forceSP() :
                                       StatementPartitioning.forceMP();
            StatementCompiler.compile(compiler, hsql, catalog, db,
                    estimates, catalogStmt, stmt.getText(), stmt.getJoinOrder(),
                    detMode, partitioning);

            if (partitioning.wasSpecifiedAsSingle()) {
                procWantsCommonPartitioning = false; // Don't try to infer what's already been asserted.
                // The planner does not currently attempt to second-guess a plan declared as single-partition, maybe some day.
                // In theory, the PartitioningForStatement would confirm the use of (only) a parameter as a partition key --
                // or if the partition key was determined to be some other constant (expression?) it might display an informational
                // message that the passed parameter is assumed to be equal to the hard-coded partition key constant (expression).

                // Validate any inferred statement partitioning given the statement's possible usage, until a contradiction is found.
            }
            else if (procWantsCommonPartitioning) {
                // Only consider statements that are capable of running SP with a partitioning parameter that does not seem to
                // conflict with the partitioning of prior statements.
                if (partitioning.getCountOfIndependentlyPartitionedTables() == 1) {
                    AbstractExpression statementPartitionExpression = partitioning.singlePartitioningExpressionForReport();
                    if (statementPartitionExpression != null) {
                        if (commonPartitionExpression == null) {
                            commonPartitionExpression = statementPartitionExpression;
                            exampleSPstatement = stmt.getText();
                            exampleSPvalue = partitioning.getInferredPartitioningValue();
                        }
                        else if (commonPartitionExpression.equals(statementPartitionExpression) ||
                                   (statementPartitionExpression instanceof ParameterValueExpression &&
                                    commonPartitionExpression instanceof ParameterValueExpression)) {
View Full Code Here


        Map<String,Object> bindings = binding.getVariables();
        ImmutableMap.Builder<String, SQLStmt> builder = ImmutableMap.builder();

        for (Map.Entry<String, Object>entry: bindings.entrySet()) {
            if (entry.getValue() != null && entry.getValue() instanceof SQLStmt) {
                SQLStmt statement = SQLStmt.class.cast(entry.getValue());
                builder.put(entry.getKey(), statement);
            }
        }

        @SuppressWarnings("unchecked")
View Full Code Here

TOP

Related Classes of org.voltdb.SQLStmt

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.