Package org.voltdb.planner.parseinfo

Examples of org.voltdb.planner.parseinfo.StmtTargetTableScan


                String expressionjson = index.getExpressionsjson();
                if (expressionjson.isEmpty()) {
                    continue;
                }
                List<AbstractExpression> indexedExprs = null;
                StmtTableScan tableScan = new StmtTargetTableScan(srcTable, srcTable.getTypeName());
                try {
                    indexedExprs = AbstractExpression.fromJSONArrayString(expressionjson, tableScan);
                } catch (JSONException e) {
                    e.printStackTrace();
                    assert(false);
View Full Code Here


                            }
                        }
                        String col_add = "";
                        String exprStrings = new String();
                        if (catalog_idx.getExpressionsjson() != null && !catalog_idx.getExpressionsjson().equals("")) {
                            StmtTargetTableScan tableScan = new StmtTargetTableScan(catalog_tbl, catalog_tbl.getTypeName());
                            try {
                                List<AbstractExpression> expressions = AbstractExpression.fromJSONArrayString(catalog_idx.getExpressionsjson(), tableScan);
                                String sep = "";
                                for (AbstractExpression expr : expressions) {
                                    exprStrings += sep + expr.explain(catalog_tbl.getTypeName());
                                    sep = ",";
                                }
                            }
                            catch (JSONException e) {
                            }
                            sb.append(col_add + exprStrings);
                        }
                        else {
                            for (ColumnRef catalog_colref : CatalogUtil.getSortedCatalogItems(catalog_idx.getColumns(), "index")) {
                                sb.append(col_add + catalog_colref.getColumn().getTypeName() );
                                col_add = ", ";
                            } // FOR
                        }
                        sb.append(")");
                    }
                    else
                    if (const_type == ConstraintType.LIMIT) {
                        sb.append("LIMIT PARTITION ROWS " + String.valueOf(catalog_tbl.getTuplelimit()) );
                    }

                }
                if (catalog_idx.getTypeName().startsWith(HSQLInterface.AUTO_GEN_PREFIX) ||
                        catalog_idx.getTypeName().startsWith(HSQLInterface.AUTO_GEN_MATVIEW) ) {
                    skip_indexes.add(catalog_idx);
                }

            // Foreign Key
            } else if (const_type == ConstraintType.FOREIGN_KEY) {
                Table catalog_fkey_tbl = catalog_const.getForeignkeytable();
                String col_add = "";
                String our_columns = "";
                String fkey_columns = "";
                for (ColumnRef catalog_colref : catalog_const.getForeignkeycols()) {
                    // The name of the ColumnRef is the column in our base table
                    Column our_column = catalog_tbl.getColumns().getIgnoreCase(catalog_colref.getTypeName());
                    assert(our_column != null);
                    our_columns += col_add + our_column.getTypeName();

                    Column fkey_column = catalog_colref.getColumn();
                    assert(fkey_column != null);
                    fkey_columns += col_add + fkey_column.getTypeName();

                    col_add = ", ";
                }
                sb.append(add + spacer + "CONSTRAINT " + catalog_const.getTypeName() + " " +
                                         "FOREIGN KEY (" + our_columns + ") " +
                                         "REFERENCES " + catalog_fkey_tbl.getTypeName() + " (" + fkey_columns + ")" );
            }
            skip_constraints.add(catalog_const);
        }

        if (catalog_tbl.getTuplelimit() != Integer.MAX_VALUE) {
            sb.append(add + spacer + "LIMIT PARTITION ROWS " + String.valueOf(catalog_tbl.getTuplelimit()) );
        }

        if (viewQuery != null) {
            sb.append("\n) AS \n");
            sb.append(spacer + viewQuery + ";\n");
        }
        else {
            sb.append("\n);\n");
        }

        // Partition Table
        if (catalog_tbl.getPartitioncolumn() != null && viewQuery == null) {
            sb.append("PARTITION TABLE " + catalog_tbl.getTypeName() + " ON COLUMN " +
                    catalog_tbl.getPartitioncolumn().getTypeName() + ";\n" );
        }

        // All other Indexes
        for (Index catalog_idx : catalog_tbl.getIndexes()) {
            if (skip_indexes.contains(catalog_idx)) continue;

            if (catalog_idx.getUnique()) {
                if (catalog_idx.getAssumeunique()) {
                    sb.append("CREATE ASSUMEUNIQUE INDEX ");
                }
                else {
                    sb.append("CREATE UNIQUE INDEX ");
                }
            }
            else {
                sb.append("CREATE INDEX ");
            }


            sb.append(catalog_idx.getTypeName() +
                   " ON " + catalog_tbl.getTypeName() + " (");
            add = "";

            String jsonstring = catalog_idx.getExpressionsjson();

            if (jsonstring.isEmpty()) {
                for (ColumnRef catalog_colref : CatalogUtil.getSortedCatalogItems(catalog_idx.getColumns(), "index")) {
                    sb.append(add + catalog_colref.getColumn().getTypeName() );
                    add = ", ";
                }
            } else {
                List<AbstractExpression> indexedExprs = null;
                try {
                    indexedExprs = AbstractExpression.fromJSONArrayString(jsonstring,
                            new StmtTargetTableScan(catalog_tbl, catalog_tbl.getTypeName()));
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                for (AbstractExpression expr : indexedExprs) {
View Full Code Here

    private StmtTableScan addTableToStmtCache(String tableName, String tableAlias, AbstractParsedStmt subquery) {
        // Create an index into the query Catalog cache
        StmtTableScan tableScan = m_tableAliasMap.get(tableAlias);
        if (tableScan == null) {
            if (subquery == null) {
                tableScan = new StmtTargetTableScan(getTableFromDB(tableName), tableAlias);
            } else {
                tableScan = new StmtSubqueryScan(subquery, tableAlias);
            }
            m_tableAliasMap.put(tableAlias, tableScan);
        }
View Full Code Here

                    "Please either simplify the subquery or use a SELECT followed by an INSERT.";
                return null;
            }

            List<StmtTableScan> tables = new ArrayList<>();
            StmtTargetTableScan stmtTargetTableScan = new StmtTargetTableScan(targetTable, targetTable.getTypeName());
            tables.add(stmtTargetTableScan);
            tables.add(subquery);

            // Create value equivalence between the partitioning column of the target table
            // and the corresponding expression produced by the subquery.

            HashMap<AbstractExpression, Set<AbstractExpression>>  valueEquivalence = new HashMap<>();
            int i = 0;
            Column partitioningCol = targetTable.getPartitioncolumn();
            boolean setEquivalenceForPartitioningCol = false;
            for (Column col : insertStmt.m_columns.keySet()) {
                if (partitioningCol.compareTo(col) == 0) {
                    List<SchemaColumn> partitioningColumns = stmtTargetTableScan.getPartitioningColumns();
                    assert(partitioningColumns.size() == 1);
                    AbstractExpression targetPartitionColExpr = partitioningColumns.get(0).getExpression();
                    TupleValueExpression selectedExpr = subquery.getOutputExpression(i);
                    assert(!valueEquivalence.containsKey(targetPartitionColExpr));
                    assert(!valueEquivalence.containsKey(selectedExpr));
View Full Code Here

TOP

Related Classes of org.voltdb.planner.parseinfo.StmtTargetTableScan

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.