Package edu.brown.designer

Examples of edu.brown.designer.AccessGraph


    /**
     * testGenerateColumnOrder
     */
    public void testGenerateColumnOrder() throws Exception {
        AccessGraph agraph = this.partitioner.generateAccessGraph();
        assertNotNull(agraph);

        Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SUBSCRIBER);
        Column expected[] = {
            this.getColumn(catalog_tbl, "S_ID"),
View Full Code Here


       
        // Setup everything else
        this.catalog_proc = this.getProcedure(TARGET_PROCEDURE);
        this.info = new DesignerInfo(catalogContext, workload);
       
        this.agraph = new AccessGraph(catalog_db);
        this.generator = new AccessGraphGenerator(this.info, this.catalog_proc);
    }
View Full Code Here

   
    /**
     * testFindEdgeSetUsingColumn
     */
    public void testFindEdgeSetUsingColumn() throws Exception {
        AccessGraph agraph = new AccessGraph(catalog_db);
        new AccessGraphGenerator(this.info, this.catalog_proc).generate(agraph);
        agraph.setVerbose(true);
       
        Table catalog_tbl = this.getTable("STOCK");
        Column catalog_col = this.getColumn(catalog_tbl, "S_W_ID");
       
        DesignerVertex v = agraph.getVertex(catalog_tbl);
        assertNotNull(v);
        Collection<DesignerEdge> edges = agraph.findEdgeSet(v, catalog_col);
        assertNotNull(edges);
        assert(agraph.getEdgeCount() != edges.size());
    }
View Full Code Here

   
    /**
     * testMultiPass
     */
    public void testMultiPass() throws Exception {
        AccessGraph agraph0 = new AccessGraph(catalog_db);
        new AccessGraphGenerator(this.info, this.catalog_proc).generate(agraph0);
       
        AccessGraph agraph1 = new AccessGraph(catalog_db);
        new AccessGraphGenerator(this.info, this.catalog_proc).generate(agraph1);
       
        // Make sure that all of the weights are the same
        for (DesignerEdge e0 : agraph0.getEdges()) {
            List<DesignerVertex> vertices0 = new ArrayList<DesignerVertex>(agraph0.getIncidentVertices(e0));
            DesignerVertex v1_0  = agraph1.getVertex(vertices0.get(0).getCatalogKey());
            assertNotNull("Missing vertex " + vertices0.get(0), v1_0);
            DesignerVertex v1_1  = agraph1.getVertex(vertices0.get(1).getCatalogKey());
            assertNotNull("Missing vertex " + vertices0.get(1), v1_1);
           
            DesignerEdge e1 = agraph1.findEdge(v1_0, v1_1);
            assertNotNull("Missing edge " + e0, e1);
           
            assertEquals(e0.getIntervalCount(), e1.getIntervalCount());
            for (int i = 0, cnt = e0.getIntervalCount(); i < cnt; i++) {
                assertEquals("Mismatched weights for " + e0 + " [" + i + "]", e0.getWeight(i), e1.getWeight(i));
View Full Code Here

       
        // Setup everything else
        this.catalog_proc = this.getProcedure(TARGET_PROCEDURE);
        this.info = new DesignerInfo(catalogContext, workload);
       
        this.agraph = new AccessGraph(catalog_db);
        this.generator = new AccessGraphGenerator(this.info, this.catalog_proc);
    }
View Full Code Here

   
    /**
     * testInsertHistory
     */
    public void testInsertHistory() throws Exception {
        agraph = new AccessGraph(catalog_db);
        catalog_proc = this.getProcedure(paymentByCustomerId.class);
        this.generator = new AccessGraphGenerator(this.info, catalog_proc);
        this.generator.generate(agraph);
        assert(agraph.getVertexCount() > 0);
       
View Full Code Here

    public void testConvertToSingleColumnEdges() throws Exception {
        agraph = AccessGraphGenerator.generateGlobal(this.info);
//        agraph.setVerbose(true);
//        System.err.println("Dumping AccessGraph to " + FileUtil.writeStringToFile("/tmp/global_tpcc.dot", GraphvizExport.export(agraph, "tpcc")));
       
        AccessGraph single_agraph = AccessGraphGenerator.convertToSingleColumnEdges(catalog_db, agraph);
        assertNotNull(single_agraph);
//        single_agraph.setVerbose(true);
//        System.err.println("Dumping AccessGraph to " + FileUtil.writeStringToFile("/tmp/single_tpcc.dot", GraphvizExport.export(single_agraph, "tpcc")));

        // Make sure that it has all of our tables except HISTORY
        for (Table catalog_tbl : catalogContext.getDataTables()) {
            if (catalog_tbl.getName().equalsIgnoreCase("HISTORY")) continue;
            DesignerVertex v = single_agraph.getVertex(catalog_tbl);
            assertNotNull(catalog_tbl.getName(), v);
            System.err.println(catalog_tbl + ": " + v);
        } // FOR
       
        // Make a new ColumnSet that combines all the ColumnSets of all edges in the original AccessGraph
        DesignerVertex v0, v1;
        Collection<DesignerEdge> edges;
        boolean found = false;
        for (Table catalog_tbl0 : catalog_db.getTables()) {
            try {
                v0 = agraph.getVertex(catalog_tbl0);
            } catch (IllegalArgumentException ex) {
                continue;
            }
            for (Table catalog_tbl1 : catalog_db.getTables()) {
                try {
                    v1 = agraph.getVertex(catalog_tbl1);
                } catch (IllegalArgumentException ex) {
                    continue;
                }
                if (catalog_tbl0.equals(catalog_tbl1)) continue;
           
                PredicatePairs global_cset = new PredicatePairs();
                try {
                    edges = agraph.findEdgeSet(v0, v1);
                } catch (IllegalArgumentException ex) {
                    continue;
                }
                found = true;
                for (DesignerEdge e : edges) {
                    PredicatePairs e_cset = e.getAttribute(EdgeAttributes.COLUMNSET);
                    assertNotNull(e_cset);
                    global_cset.addAll(e_cset);
                } // FOR
//                System.err.println(String.format("%s <-> %s: %d", catalog_tbl0, catalog_tbl1, edges.size()));
               
                // Now check to make sure that there are no edges that have some funky ColumnSet entry that
                // wasn't in our original graph
                for (DesignerEdge e : single_agraph.findEdgeSet(v0, v1)) {
                    PredicatePairs e_cset = e.getAttribute(EdgeAttributes.COLUMNSET);
                    assertNotNull(e_cset);
                    assertEquals(e_cset.toString(), 1, e_cset.size());
                    CatalogPair entry = CollectionUtil.first(e_cset);
                    assertNotNull(entry);
View Full Code Here

     * @throws Exception
     */
    protected void init(DesignerHints hints) throws Exception {
        assert (hints != null);
        this.init_called = true;
        AccessGraph first = this.generateAccessGraph();
        this.agraph = AccessGraphGenerator.convertToSingleColumnEdges(info.catalogContext.database, first);

        // Set the limits initially from the hints file
        if (hints.limit_back_tracks != null)
            this.last_backtrack_limit = new Double(hints.limit_back_tracks);
        if (hints.limit_local_time != null)
            this.last_localtime_limit = new Double(hints.limit_local_time);
        if (this.last_entropy_weight == null)
            this.last_entropy_weight = hints.weight_costmodel_skew;

        // HACK: Reload the correlations file so that we can get the proper
        // catalog objects
        this.mappings.load(info.getMappingsFile(), info.catalogContext.database);

        // this.agraph.setVertexVerbose(true);
        // GraphvizExport<DesignerVertex, DesignerEdge> gv = new
        // GraphvizExport<DesignerVertex, DesignerEdge>(this.agraph);
        // gv.setCollapseEdges(true);
        // System.err.println("ORIG GRAPH:" + gv.writeToTempFile());
        //
        // gv = new GraphvizExport<DesignerVertex,
        // DesignerEdge>(this.single_agraph);
        // gv.setCollapseEdges(true);
        // System.err.println("SINGLE GRAPH:" + gv.writeToTempFile());

        // Gather all the information we need about each table
        for (Table catalog_tbl : PartitionerUtil.generateTableOrder(info, this.agraph, hints)) {

            // Ignore this table if it's not used in the AcessGraph
            DesignerVertex v = null;
            try {
                v = this.agraph.getVertex(catalog_tbl);
            } catch (IllegalArgumentException ex) {
                // IGNORE
            }
            if (v == null) {
                LOG.warn(String.format("Ignoring %s - No references in workload AccessGraph", catalog_tbl));
                this.ignore_tables.add(catalog_tbl);
                continue;
            }

            // Potential Partitioning Attributes
            Collection<Column> columns = PartitionerUtil.generateColumnOrder(info, this.agraph, catalog_tbl, hints, false, true);
            assert (!columns.isEmpty()) : "No potential partitioning columns selected for " + catalog_tbl;
            this.orig_table_attributes.put(catalog_tbl, (ListOrderedSet<Column>) CollectionUtil.addAll(new ListOrderedSet<Column>(), columns));

            // Table Size (when the table is and is not replicated)
            TableStatistics ts = info.stats.getTableStatistics(catalog_tbl);
            this.table_nonreplicated_size.put(catalog_tbl, Math.round(ts.tuple_size_total / (double) this.num_partitions));
            this.table_replicated_size.put(catalog_tbl, ts.tuple_size_total);

            if (trace.val)
                LOG.trace(catalog_tbl.getName() + ": " + columns);
        } // FOR

        // We also need to know some things about the Procedures and their
        // ProcParameters
        Histogram<String> workloadHistogram = info.workload.getProcedureHistogram();
        for (Procedure catalog_proc : info.catalogContext.database.getProcedures()) {
            // Skip if we're explicitly force to ignore this guy
            if (PartitionerUtil.shouldIgnoreProcedure(hints, catalog_proc)) {
                if (debug.val) LOG.warn(String.format("Ignoring %s - Set to be ignored by the DesignerHints.", catalog_proc));
                this.ignore_procs.add(catalog_proc);
                continue;
            }
            // Or if there are not transactions in the sample workload
            else if (workloadHistogram.get(CatalogKey.createKey(catalog_proc), 0) == 0) {
                if (debug.val) LOG.warn(String.format("Ignoring %s - No transaction records in sample workload.", catalog_proc));
                this.ignore_procs.add(catalog_proc);
                continue;
            }

            Collection<Column> columns = CatalogUtil.getReferencedColumns(catalog_proc);
            if (columns.isEmpty()) {
                if (debug.val) LOG.warn(String.format("Ignoring %s - Does not reference any columns in its queries.", catalog_proc));
                this.ignore_procs.add(catalog_proc);
                continue;
            }
            this.proc_columns.put(catalog_proc, columns);

            // Aha! Use the Procedure-specific AccessGraph to build our
            // Histogram! Where's your god now??
            AccessGraph proc_agraph = this.designer.getAccessGraph(catalog_proc);
            assert (proc_agraph != null);
            // if (catalog_proc.getName().equals("GetAccessData")) {
            // GraphVisualizationPanel.createFrame(proc_agraph).setVisible(true);
            // }
            this.proc_column_histogram.put(catalog_proc, PartitionerUtil.generateProcedureColumnAccessHistogram(info, hints, proc_agraph, catalog_proc));
View Full Code Here

        // procedure
        // ----------------------------------------------------
        final Vector<PartitionTree> partition_trees = new Vector<PartitionTree>();
        List<Thread> threads = new ArrayList<Thread>();
        for (final Procedure catalog_proc : info.catalogContext.database.getProcedures()) {
            final AccessGraph agraph = designer.getAccessGraph(catalog_proc);
            if (agraph == null)
                continue;
            LOG.debug("Creating a new thread for contructing a PartitionForest for " + catalog_proc);
            Thread thread = new Thread() {
                @Override
View Full Code Here

     */
    public static AccessGraph generateGlobal(DesignerInfo info) {
        if (d)
            LOG.debug("Generating AccessGraph for entire catalog");

        AccessGraph agraph = new AccessGraph(info.catalogContext.database);
        for (Procedure catalog_proc : info.catalogContext.database.getProcedures()) {
            // Skip if there are no transactions in the workload for this
            // procedure
            assert (info.workload != null);
            if (info.workload.getTraces(catalog_proc).isEmpty()) {
View Full Code Here

TOP

Related Classes of edu.brown.designer.AccessGraph

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.