Examples of MaterializedViewInfo


Examples of org.voltdb.catalog.MaterializedViewInfo

            fields_before.put(catalog_stmt, this.generateFieldMap(catalog_stmt));
        } // FOR
//        System.err.println("BEFORE:\n" + StringUtil.formatMaps(fields_before));
       
        // AFTER!
        MaterializedViewInfo catalog_view = vpc.applyUpdate();
        assertNotNull(catalog_view);
        assertEquals(CatalogUtil.getVerticalPartition(catalog_tbl), catalog_view);
        for (Statement catalog_stmt : vpc.getOptimizedQueries()) {
            Map<String, Object> before_m = fields_before.get(catalog_stmt);
            assertNotNull(before_m);
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

    public void testOrderByQuery() throws Exception {
        String vp_cols[] = { "S_ID", "SUB_NBR", "MSC_LOCATION" };
        super.setUp(new MockProjectBuilder(vp_cols), true);
       
        Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SUBSCRIBER);
        MaterializedViewInfo view = CatalogUtil.getVerticalPartition(catalog_tbl);
        assertNotNull(view);
        assertEquals(CatalogUtil.debug(view.getGroupbycols()), vp_cols.length, view.getGroupbycols().size());
       
        Procedure catalog_proc = this.getProcedure("TestOrderBy");
        Statement catalog_stmt = CollectionUtil.first(catalog_proc.getStatements());
        assert(catalog_stmt != null) : catalog_proc.getStatements();
        Object params[] = new Object[]{ "ABC" };
       
        Integer base_partition = new Random().nextInt(NUM_PARTITIONS);
       
        // We don't actually care whether this got turned to a single-partition txn
        // We just care that it got optimized properly with the ORDER BY
        VerticalPartitionPlanner vp_planner = new VerticalPartitionPlanner(catalog_db, true);
        boolean ret = vp_planner.optimizeStatement(catalog_stmt);
        assert(ret);
        p_estimator.clear();
        PartitionSet new_partitions = new PartitionSet();
        p_estimator.getAllPartitions(new_partitions, catalog_stmt, params, base_partition);
        assertNotNull(new_partitions);
//        System.err.println("NEW PARTITIONS: " + new_partitions);
        assertEquals(1, new_partitions.size());
        assertEquals(base_partition, CollectionUtil.first(new_partitions));
       
        // Make sure the ORDER BY column references the vertical partition table
        CatalogUtil.clearCache(catalog_db);
        PlanNodeUtil.clearCache();
        Collection<Column> orderByCols = CatalogUtil.getOrderByColumns(catalog_stmt);
        assertNotNull(orderByCols);
        assertFalse(orderByCols.isEmpty());
//        System.err.println(PlanNodeUtil.debug(PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, false)));
        for (Column catalog_col : orderByCols) {
            Table parent = catalog_col.getParent();
            assertNotNull(parent);
            assertEquals(view.getDest(), parent);
        } // FOR
       
    }
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

        return (this.applied);
    }

    public synchronized MaterializedViewInfo createMaterializedView() {
        Table catalog_tbl = this.getParent();
        MaterializedViewInfo catalog_view = CatalogUtil.getVerticalPartition(catalog_tbl);
        if (catalog_view == null || catalog_view.getDest() == null) {
            Collection<Column> cols = this.getVerticalPartitionColumns();
            assert (cols.size() > 0) : "No Vertical Partition columns for " + this;
            if (trace.val)
                LOG.trace("Creating VerticalPartition in catalog for " + catalog_tbl + ": " + cols);
            try {
                catalog_view = VoltCompiler.addVerticalPartition(catalog_tbl, cols, true);
                assert (catalog_view != null);
            } catch (Throwable ex) {
                throw new RuntimeException("Failed to create vertical partition for " + this, ex);
            }
            if (debug.val)
                LOG.debug(String.format("Created vertical partition %s.%s: %s", catalog_tbl.getName(), catalog_view.getName(), CatalogUtil.debug(catalog_view.getDest().getColumns())));

        } else if (debug.val) {
            LOG.debug(String.format("Using existing vertical partition %s.%s: %s", catalog_tbl.getName(), catalog_view.getName(), CatalogUtil.debug(catalog_view.getDest().getColumns())));
        }
        validate(catalog_view, catalog_tbl);
        return (catalog_view);
    }
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

                    remaining_tables.add(catalog_tbl);
                }
                // Include the vertical partition for any table that is not in
                // our search neighborhood
                else if (hints.enable_vertical_partitioning && vps.containsKey(catalog_tbl) && catalog_tbl.getPartitioncolumn() instanceof VerticalPartitionColumn) {
                    MaterializedViewInfo catalog_view = vps.get(catalog_tbl);
                    assert (catalog_view != null);
                    assert (catalog_view.getDest() != null);
                    remaining_tables.add(catalog_view.getDest());
                }
            } // FOR
            if (debug.val)
                LOG.debug(String.format("Tables: %d Searchable / %d Fixed", this.search_tables.size(), remaining_tables.size()));
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

                        current_col = search_col;
                        vp_col = (VerticalPartitionColumn) search_col;
                        assert (CatalogUtil.getDatabase(vp_col).equals(info.catalogContext.database)) : String.format("VP_COL[%d] != INFO[%d]", CatalogUtil.getDatabase(vp_col).hashCode(),
                                info.catalogContext.database.hashCode());

                        MaterializedViewInfo catalog_view = vp_col.applyUpdate();
                        assert (catalog_view != null) : "Unexpected null MaterializedViewInfo for " + current_tbl + " vertical partition:\n" + vp_col;
                        if (this.cost_model.isCachingEnabled()) {
                            if (trace.val)
                                LOG.trace("Invalidating VerticalPartition Statements in cost model: " + vp_col.getOptimizedQueries());
                            this.cost_model.invalidateCache(vp_col.getOptimizedQueries());
                        }
                        TableStatistics tstats = VerticalPartitionerUtil.computeTableStatistics(vp_col, info.stats);
                        assert (tstats != null);
                        // Add the vp's sys table to the list of tables that we
                        // need to estimate the memory
                        assert (catalog_view.getDest() != null) : "Missing parent table for " + catalog_view.fullName();
                        assert (this.current_vertical_partitions.contains(catalog_view.getDest()) == false) : vp_col;
                        this.current_vertical_partitions.add(catalog_view.getDest());
                    }
                    // MultiColumn
                    else if (search_col instanceof MultiColumn) {
                        // Nothing special?
                        current_tbl.setIsreplicated(false);
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

                this.cost_model.invalidateCache(vp_col.getOptimizedQueries());
            }

            // Make sure we remove the sys table from the list of tables
            // that we need to estimate the memory from
            MaterializedViewInfo catalog_view = vp_col.getViewCatalog();
            assert (catalog_view != null) : vp_col;
            assert (catalog_view.getDest() != null) : vp_col;
            assert (this.current_vertical_partitions.contains(catalog_view.getDest())) : vp_col;
            this.current_vertical_partitions.remove(catalog_view.getDest());
        }
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

     * @param vp_col
     * @param stats
     * @return
     */
    public static TableStatistics computeTableStatistics(VerticalPartitionColumn vp_col, WorkloadStatistics stats) {
        MaterializedViewInfo catalog_view = vp_col.createMaterializedView();
        Table view_tbl = catalog_view.getDest();
        assert (view_tbl != null) : "Destination table for " + catalog_view + " is null?";
        TableStatistics tbl_stats = stats.getTableStatistics(view_tbl);
        if (tbl_stats == null) {
            tbl_stats = new TableStatistics(view_tbl);
            stats.addTableStatistics(view_tbl, tbl_stats);

            Table orig_tbl = catalog_view.getParent();
            TableStatistics orig_tbl_stats = stats.getTableStatistics(orig_tbl);
            assert (orig_tbl_stats != null) : "Missing TableStatistics " + orig_tbl;

            tbl_stats.readonly = true;
            tbl_stats.tuple_count_total = orig_tbl_stats.tuple_count_total;
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

     * @param c
     * @return
     */
    public static boolean generateOptimizedQueries(Database catalog_db, VerticalPartitionColumn c) {
        boolean ret = false;
        MaterializedViewInfo catalog_view = CatalogUtil.getVerticalPartition((Table) c.getParent());
        if (catalog_view == null)
            catalog_view = c.createMaterializedView();
        assert (catalog_view != null);
        assert (catalog_view.getGroupbycols().isEmpty() == false) : String.format("Missing columns for VerticalPartition view %s\n%s", catalog_view.fullName(), c);

        List<String> columnNames = c.getVerticalPartitionColumnNames();
        VerticalPartitionPlanner vp_planner = new VerticalPartitionPlanner(catalog_db, catalog_view);
        Map<Statement, Statement> optimized = null;
        try {
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

        virtual_tbl.setMaterializer(catalog_tbl);
        virtual_tbl.setSystable(true);
        virtual_tbl.getColumns().clear();
       
        // Create MaterializedView and link it to the virtual table
        MaterializedViewInfo catalog_view = catalog_tbl.getViews().add(viewName);
        catalog_view.setVerticalpartition(true);
        catalog_view.setDest(virtual_tbl);
        List<Column> indexColumns = new ArrayList<Column>();

        Column partition_col = catalog_tbl.getPartitioncolumn();
        if (partition_col instanceof VerticalPartitionColumn) {
            partition_col = ((VerticalPartitionColumn)partition_col).getHorizontalColumn();
        }
        if (debug.val)
            LOG.debug(catalog_tbl.getName() + " Partition Column: " + partition_col);
       
        int i = 0;
        assert(catalog_cols != null);
        assert(catalog_cols.isEmpty() == false) : "No vertical partitioning columns for " + catalog_view.fullName();
        for (Column catalog_col : catalog_cols) {
            // MaterializedView ColumnRef
            ColumnRef catalog_ref = catalog_view.getGroupbycols().add(catalog_col.getName());
            catalog_ref.setColumn(catalog_col);
            catalog_ref.setIndex(i++);
           
            // VirtualTable Column
            Column virtual_col = virtual_tbl.getColumns().add(catalog_col.getName());
View Full Code Here

Examples of org.voltdb.catalog.MaterializedViewInfo

            return (false);
        }
        Collection<Column> output_cols = PlanNodeUtil.getOutputColumnsForStatement(catalog_stmt);
        assert (output_cols.isEmpty() == false);
        for (Table catalog_tbl : tables) {
            MaterializedViewInfo catalog_view = this.vp_views.get(catalog_tbl);
            assert(catalog_view != null);
            assert(catalog_view.getGroupbycols().isEmpty() == false) :
                String.format("Missing vertical partitioning columns in %s when trying to process %s\n%s\nCACHED: %s",
                              catalog_view.fullName(), catalog_stmt.fullName(), CatalogUtil.debug(catalog_view), CatalogUtil.debug(this.vp_columns.get(catalog_tbl)));
            Collection<Column> view_cols = CatalogUtil.getColumns(catalog_view.getGroupbycols());
            assert(view_cols.isEmpty() == false) : "Missing vertical partitioning columns in " + catalog_view.fullName() + " when trying to process " + catalog_stmt.fullName();
            Column partitioning_col = catalog_tbl.getPartitioncolumn();
            assert(partitioning_col != null);

            // The current vertical partition is valid for this query if all the
            // following are true:
            // (1) The partitioning_col is in output_cols
            // (2) The partitioning_col is *not* in the predicate_cols
            // (3) At least one of the vertical partition's columns is in
            // predicate_cols
            if (debug.val) {
                Map<String, Object> m = new LinkedHashMap<String, Object>();
                m.put("VerticalP", catalog_view.getName());
                m.put("Partitioning Col", partitioning_col.fullName());
                m.put("Output Cols", output_cols);
                m.put("Statement Cols", stmt_cols);
                m.put("VerticalP Cols", view_cols);
                LOG.debug(String.format("Checking whether %s can use vertical partition for %s\n%s", catalog_stmt.fullName(), catalog_tbl.getName(), StringUtil.formatMaps(m)));
            }
//            if (output_cols.contains(partitioning_col) == false) {
//                if (debug.val)
//                    LOG.warn("Output Columns do not contain horizontal partitioning column");
//            }
//            else
            if (view_cols.containsAll(output_cols) == false) {
                if (debug.val)
                    LOG.warn("Vertical Partition columns do not contain output columns");
            }
            /** Is this needed?
            else if (stmt_cols.contains(partitioning_col) == true) {
                if (debug.val)
                    LOG.warn("Statement Columns contains horizontal partition column");
            }
            **/
            else if (view_cols.containsAll(stmt_cols) == false) {
                if (debug.val)
                    LOG.warn("The Vertical Partition Columns does not contain all of the Statement Columns " + CollectionUtils.subtract(view_cols, stmt_cols));
            }
            else {
                if (debug.val)
                    LOG.debug("Valid VP Candidate: " + catalog_tbl);
                StatementRewrite rewrite = this.stmt_rewrites.get(catalog_stmt);
                if (rewrite == null) {
                    rewrite = new StatementRewrite();
                    this.stmt_rewrites.put(catalog_stmt, rewrite);
                }
                rewrite.put(catalog_tbl, catalog_view.getDest());
            }
        } // FOR
       
        // Check to make sure that we were able to generate a StatementRewrite candidate for this one
        StatementRewrite rewrite = this.stmt_rewrites.get(catalog_stmt);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.