Package edu.brown.utils

Examples of edu.brown.utils.PredicatePairs


                    this.repcolumns.put(catalog_tbl, ReplicatedColumn.get(catalog_tbl));
                }
            }

            for (DesignerEdge e : this.agraph.getIncidentEdges(v)) {
                PredicatePairs cset = e.getAttribute(AccessGraph.EdgeAttributes.COLUMNSET);
                assert (cset != null);
                Column catalog_col = CollectionUtil.first(cset.findAllForParent(Column.class, catalog_tbl));
                Collection<Column> candidates = new HashSet<Column>();

                if (catalog_col == null)
                    LOG.fatal("Failed to find column for " + catalog_tbl + " in ColumnSet:\n" + cset);
View Full Code Here


            Set<Column> used_cols = new HashSet<Column>();
            Collection<DesignerEdge> edges = agraph.getIncidentEdges(v);
            if (edges == null)
                continue;
            for (DesignerEdge e : edges) {
                PredicatePairs cset = e.getAttribute(agraph, AccessGraph.EdgeAttributes.COLUMNSET);
                assert (cset != null) : e.debug();
                Collection<Column> cols = cset.findAllForParent(Column.class, catalog_tbl);
                assert (cols != null) : catalog_tbl + "\n" + cset.debug();
                used_cols.addAll(cols);
            }
            int num_cols = used_cols.size();

            // Picking columns + repl
View Full Code Here

            for (DesignerEdge edge : agraph.getEdges()) {
                ArrayList<DesignerVertex> vertices = new ArrayList<DesignerVertex>();
                vertices.addAll(agraph.getIncidentVertices(edge));
                // FIXME
                if (true || !(ptree.getPath(vertices.get(0), vertices.get(1)).isEmpty() && ptree.getPath(vertices.get(1), vertices.get(0)).isEmpty())) {
                    PredicatePairs cset = (PredicatePairs) (edge.getAttribute(AccessGraph.EdgeAttributes.COLUMNSET.name()));
                    for (DesignerVertex vertex : vertices) {
                        Table catalog_tbl = vertex.getCatalogItem();
                        Collection<Column> edge_columns = cset.findAllForParent(Column.class, catalog_tbl);

                        //
                        // Exclusion: Check whether this table is already
                        // partitioned on these columns
                        //
                        PartitionEntry pentry = plan.getTableEntries().get(catalog_tbl);
                        if (pentry == null) {
                            LOG.warn("PartitionEntry is null for " + catalog_tbl);
                            continue;
                            // } else if (pentry.getMethod() !=
                            // PartitionMethodType.REPLICATION &&
                            // pentry.getAttributes().equals(edge_columns)) {
                            // LOG.info(catalog_tbl +
                            // " is already partitioned on " + edge_columns +
                            // ". Skipping...");
                            // continue;
                        }
                        //
                        // Exclusion: Check whether this is the table's primary
                        // key
                        //
                        Collection<Column> pkeys = CatalogUtil.getPrimaryKeyColumns(catalog_tbl);
                        if (pkeys.containsAll(edge_columns) && edge_columns.containsAll(pkeys)) {
                            LOG.info(catalog_tbl + "'s primary key already contains " + edge_columns + ". Skipping...");
                            continue;
                        }
                        //
                        // Exclusion: These columns are only used in INSERTS
                        //
                        Map<QueryType, Integer> query_counts = cset.getQueryCounts();
                        if (query_counts.get(QueryType.SELECT) == 0 && query_counts.get(QueryType.UPDATE) == 0 && query_counts.get(QueryType.DELETE) == 0) {
                            LOG.info("The columns " + edge_columns + " are only used in INSERT operations on " + catalog_tbl + ". Skipping...");
                            continue;
                        }
View Full Code Here

     */
    public Collection<DesignerEdge> findEdgeSet(DesignerVertex v, Column catalog_col) {
        assert (v != null);
        Set<DesignerEdge> edges = new HashSet<DesignerEdge>();
        for (DesignerEdge e : this.getIncidentEdges(v)) {
            PredicatePairs cset = e.getAttribute(EdgeAttributes.COLUMNSET);
            assert (cset != null);
            if (cset.findAll(catalog_col).isEmpty() == false) {
                edges.add(e);
            }
        } // FOR
        return (edges);
    }
View Full Code Here

            // for (Entry<String, Object> entry :
            // e.getAttributeValues(this).entrySet()) {
            // sb.append(String.format("\n => %-15s%s", entry.getKey()+":",
            // entry.getValue().toString()));
            // }
            PredicatePairs cset = e.getAttribute(EdgeAttributes.COLUMNSET.name());
            assert (cset != null);
            sb.append("\n").append(cset.debug());
        }
        return (sb.toString());
    }
View Full Code Here

                    DesignerVertex v1 = CollectionUtil.get(vertices, 1);
                    boolean self = (v0.equals(v) && v1.equals(v));
                    column_histogram = (self ? self_column_histogram : join_column_histogram);

                    double edge_weight = e.getTotalWeight();
                    PredicatePairs cset = e.getAttribute(AccessGraph.EdgeAttributes.COLUMNSET);
                    if (trace.val)
                        LOG.trace("Examining ColumnSet for " + e.toString(true));

                    Histogram<Column> cset_histogram = cset.buildHistogramForType(Column.class);
                    Collection<Column> columns = cset_histogram.values();
                    if (trace.val)
                        LOG.trace("Constructed Histogram for " + catalog_tbl + " from ColumnSet:\n"
                                + cset_histogram.setDebugLabels(CatalogUtil.getHistogramLabels(cset_histogram.values())).toString(100, 50));
                    for (Column catalog_col : columns) {
View Full Code Here

                    if (cp.getStatement0().equals(stmt)) {
                        cache.conflicts.put(cp.getStatement1(), cp);
                    }
                } // FOR
               
                PredicatePairs cset = CatalogUtil.extractStatementPredicates(stmt, false);
                Map<Table, StmtParameter[]> tableParams = new HashMap<Table, StmtParameter[]>();
                List<StmtParameter> stmtParamOffsets = new ArrayList<StmtParameter>();
                for (Table tbl : CatalogUtil.getReferencedTables(stmt)) {
                    Column pkeys[] = this.pkeysCache.get(tbl);
                    if (trace.val) LOG.trace(tbl + " => " + Arrays.toString(pkeys));
                    if (pkeys == null) {
                        LOG.warn("Unexpected null primary keys for " + tbl);
                        continue;
                    }
                    for (Column col : pkeys) {
                        Collection<StmtParameter> params = cset.findAllForOther(StmtParameter.class, col);
                        // If there are more than one, then it should always conflict
                        if (params.size() > 1) {
                            // TODO
                            LOG.warn(String.format("There are %d %s mapped to the primary key column %s. " +
                                     "Marking %s as always conflicting with %s",
View Full Code Here

   
    @Override
    protected void setUp() throws Exception {
        super.setUp(ProjectType.TPCC);
       
        this.cset = new PredicatePairs();
        this.catalog_proc = this.getProcedure(neworder.class);
        this.catalog_tbl0 = this.getTable("CUSTOMER");
        this.catalog_tbl1 = this.getTable("ORDERS");
       
        cset.add(this.getColumn(catalog_tbl0, "C_W_ID"), this.getColumn(catalog_tbl1, "O_W_ID"));
View Full Code Here

    public void testExtractStatementColumnSet() throws Exception {
        Table catalog_tbl = this.getTable(TPCCConstants.TABLENAME_DISTRICT);
        assertNotNull(catalog_tbl);
        Procedure catalog_proc = this.getProcedure("neworder");
        Statement catalog_stmt = this.getStatement(catalog_proc, "getDistrict");
        PredicatePairs cset = CatalogUtil.extractStatementPredicates(catalog_stmt, false, catalog_tbl);

        // Column -> StmtParameter Index
        Set<Pair<Column, Integer>> expected_columns = new HashSet<Pair<Column, Integer>>();
        expected_columns.add(Pair.of(catalog_tbl.getColumns().get("D_ID"), 0));
        expected_columns.add(Pair.of(catalog_tbl.getColumns().get("D_W_ID"), 1));
View Full Code Here

    public void testExtractUpdateColumnSet() throws Exception {
        Table catalog_tbl = this.getTable(TPCCConstants.TABLENAME_DISTRICT);
        Procedure catalog_proc = this.getProcedure(neworder.class);
        Statement catalog_stmt = this.getStatement(catalog_proc, "incrementNextOrderId");

        PredicatePairs cset = CatalogUtil.extractUpdateColumnSet(catalog_stmt, false, catalog_tbl);
        // System.out.println(cset.debug());

        // Column -> StmtParameter Index
        Set<Pair<Column, Integer>> expected_columns = new HashSet<Pair<Column, Integer>>();
        expected_columns.add(Pair.of(catalog_tbl.getColumns().get("D_NEXT_O_ID"), 0));
View Full Code Here

TOP

Related Classes of edu.brown.utils.PredicatePairs

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.