Package edu.brown.designer.partitioners.plan

Examples of edu.brown.designer.partitioners.plan.PartitionPlan


            Column catalog_col = this.getColumn(catalog_tbl, -1);
            catalog_tbl.setPartitioncolumn(catalog_col);
        } // FOR
       
        // Set this to be the upperbounds
        PartitionPlan ub_pplan = PartitionPlan.createFromCatalog(catalog_db);
        assertNotNull(ub_pplan);
        this.partitioner.setUpperBounds(hints, ub_pplan, Double.MAX_VALUE, 1000l);
       
        hints.max_memory_per_partition = 1;
        hints.enable_procparameter_search = false;
View Full Code Here


        catalog_tbl.setPartitioncolumn(catalog_col);
        table_visit_order.add(catalog_tbl);
        expected.put(catalog_tbl, this.getColumn(catalog_tbl, "S_ID"));
       
        // Set this to be the upperbounds
        PartitionPlan ub_pplan = PartitionPlan.createFromCatalog(catalog_db);
        assertNotNull(ub_pplan);
        this.partitioner.setUpperBounds(hints, ub_pplan, Double.MAX_VALUE, 1000l);
       
        hints.enable_multi_partitioning = false;
        hints.enable_replication_readmostly = false;
View Full Code Here

    /**
     * testGenerate
     */
    @Test
    public void testGenerate() throws Exception {
        PartitionPlan pplan = this.partitioner.generate(this.hints);
        assertNotNull(pplan);
        assertEquals(catalogContext.getDataTables().size(), pplan.getTableEntries().size());

        for (Table catalog_tbl : pplan.getTableEntries().keySet()) {
            if (catalog_tbl.getSystable()) continue;
            TableEntry pentry = pplan.getTableEntries().get(catalog_tbl);
            assertNotNull("Null PartitionEntry for " + catalog_tbl, pentry);
            Collection<Column> pkey_columns = CatalogUtil.getPrimaryKeyColumns(catalog_tbl);
            PartitionMethodType expected = (pkey_columns.isEmpty() ? PartitionMethodType.REPLICATION : PartitionMethodType.HASH);
            assertEquals("Invalid PartitionMethodType for " + catalog_tbl, expected, pentry.getMethod());
        } // FOR
View Full Code Here

     * testGenerate
     */
    @Test
    public void testGenerate() throws Exception {
        // Just make sure that something got picked for every table+procedure
        PartitionPlan pplan = this.partitioner.generate(this.hints);
        assertNotNull(pplan);
        assertEquals(catalog_db.getTables().size(), pplan.getTableEntries().size());
        Collection<PartitionMethodType> allowed_types = null;
       
        // TABLES
        allowed_types = CollectionUtil.addAll(new HashSet<PartitionMethodType>(), PartitionMethodType.HASH,
                                                                                  PartitionMethodType.REPLICATION,
                                                                                  PartitionMethodType.MAP);
        for (Entry<Table,TableEntry> e : pplan.getTableEntries().entrySet()) {
            assertNotNull(e.getKey());
            assertNotNull("Null PartitionEntry for " + e.getKey(), e.getValue());
            assert(allowed_types.contains(e.getValue().getMethod())) : "Unexpected: " + e.getValue().getMethod();
            if (e.getValue().getMethod() != PartitionMethodType.REPLICATION) assertNotNull("Null attribute for " + e.getValue(), e.getValue().getAttribute());
        } // FOR
       
        // PROCEDURES
        allowed_types = CollectionUtil.addAll(new HashSet<PartitionMethodType>(), PartitionMethodType.HASH,
                                                                                  PartitionMethodType.NONE);
        for (Entry<Procedure, ProcedureEntry> e : pplan.getProcedureEntries().entrySet()) {
            assertNotNull(e.getKey());
            assertNotNull("Null PartitionEntry for " + e.getKey(), e.getValue());
            assert(allowed_types.contains(e.getValue().getMethod())) : "Unexpected: " + e.getValue().getMethod();
            if (e.getValue().getMethod() != PartitionMethodType.NONE) assertNotNull(e.getValue().getAttribute());
        } // FOR
View Full Code Here

                                       this.getProcParameter(GetNewDestination.class, 0)));
        m.put(this.getProcedure(UpdateSubscriberData.class),
                MultiProcParameter.get(this.getProcParameter(UpdateSubscriberData.class, 0),
                                       this.getProcParameter(UpdateSubscriberData.class, 3)));

        PartitionPlan pplan = PartitionPlan.createFromMap(m);
        assertNotNull(pplan);
//        pplan.save("/tmp/tm1.manual.pplan");
       
        String json = pplan.toJSONString();
        assertFalse(json.isEmpty());
        JSONObject json_object = new JSONObject(json);
        assertNotNull(json_object);
       
        PartitionPlan clone = new PartitionPlan();
        clone.fromJSON(json_object, catalog_db);
        System.err.println(clone);
       
    }
View Full Code Here

        hints.enable_procparameter_search = false;
        hints.max_memory_per_partition = Long.MAX_VALUE;
        this.partitioner.init(this.hints);
        this.partitioner.calculateInitialSolution(hints);
        assert(this.partitioner.initial_cost > 0);
        PartitionPlan orig_solution = new PartitionPlan(this.partitioner.initial_solution);
        this.partitioner.best_solution = orig_solution;
        this.partitioner.best_memory = this.partitioner.initial_memory;
        this.partitioner.best_cost = this.partitioner.initial_cost;

        // First check whether the cost is the same simply right after the first go
        assertEquals(orig_solution, this.partitioner.best_solution);
        double new_cost = info.getCostModel().estimateWorkloadCost(catalogContext, workload);
        assert(new_cost > 0);
        assertEquals(this.partitioner.initial_cost, new_cost);
       
        // Genarate table+procedure attribute lists
        List<Table> table_attributes = new ArrayList<Table>();
        Table catalog_tbl = this.getTable(TM1Constants.TABLENAME_SUBSCRIBER);
        table_attributes.add(catalog_tbl);
       
        List<Procedure> proc_attributes = new ArrayList<Procedure>();
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            if (PartitionerUtil.isPartitionable(catalog_proc)) proc_attributes.add(catalog_proc);
        } // FOR

        // Now throw everything at the local search procedure. This should stop right away because the
        // time limits will immediately be exceeded
        this.partitioner.localSearch(hints, table_attributes, proc_attributes);
//        System.err.println(this.partitioner.best_solution);
       
        // Now check that the cost before and after are the same
        if (orig_solution.equals(this.partitioner.best_solution) == false) {
            System.err.println(orig_solution);
            System.err.println(StringUtil.repeat("*", 100));
            System.err.println(this.partitioner.best_solution);
        }
       
        for (Table tbl : catalog_db.getTables()) {
            assertEquals(tbl.toString(), orig_solution.getTableEntry(tbl), this.partitioner.best_solution.getTableEntry(tbl));
        }
// FIXME
//        info.getCostModel().clear();
//        new_cost = info.getCostModel().estimateWorkloadCost(catalog_db, workload);
//        assert(new_cost > 0);
View Full Code Here

        }

        // If given a PartitionPlan, then update the catalog
        File pplan_path = new File(args.getParam(ArgumentsParser.PARAM_PARTITION_PLAN));
        if (pplan_path.exists()) {
            PartitionPlan pplan = new PartitionPlan();
            pplan.load(pplan_path, args.catalog_db);
            if (args.getBooleanParam(ArgumentsParser.PARAM_PARTITION_PLAN_REMOVE_PROCS, false)) {
                for (Procedure catalog_proc : pplan.proc_entries.keySet()) {
                    pplan.setNullProcParameter(catalog_proc);
                } // FOR
            }
            if (args.getBooleanParam(ArgumentsParser.PARAM_PARTITION_PLAN_RANDOM_PROCS, false)) {
                for (Procedure catalog_proc : pplan.proc_entries.keySet()) {
                    pplan.setRandomProcParameter(catalog_proc);
                } // FOR
            }
            pplan.apply(args.catalog_db);
            System.out.println("Applied PartitionPlan '" + pplan_path + "' to catalog\n" + pplan);
            System.out.print(StringUtil.DOUBLE_LINE);

            if (args.hasParam(ArgumentsParser.PARAM_PARTITION_PLAN_OUTPUT)) {
                String output = args.getParam(ArgumentsParser.PARAM_PARTITION_PLAN_OUTPUT);
                if (output.equals("-"))
                    output = pplan_path.getAbsolutePath();
                pplan.save(new File(output));
                System.out.println("Saved PartitionPlan to '" + output + "'");
            }
        } else {
            System.err.println("PartitionPlan file '" + pplan_path + "' does not exist. Ignoring...");
        }
View Full Code Here

            this.calculateInitialSolution(hints);
        assert (this.initial_solution != null);

        if (this.best_solution == null) {
            LOG.info("Initializing current best solution to be initial solution");
            this.best_solution = new PartitionPlan(this.initial_solution);
            this.best_memory = this.initial_memory;
            this.best_cost = this.initial_cost;
        } else {
            LOG.info("Checking whether previously calculated best solution has the same cost");
View Full Code Here

        // -------------------------------
        // GO GO LOCAL SEARCH!!
        // -------------------------------
        Pair<PartitionPlan, BranchAndBoundPartitioner.StateVertex> pair = this.executeLocalSearch(hints, this.agraph, table_attributes, proc_attributes);
        assert (pair != null);
        PartitionPlan result = pair.getFirst();
        BranchAndBoundPartitioner.StateVertex state = pair.getSecond();

        // -------------------------------
        // Validation
        // -------------------------------
View Full Code Here

        local_search.setUpperBounds(hints, this.best_solution, this.best_cost, (long) (this.best_memory * hints.max_memory_per_partition));
        // local_search.setTraversalAttributes(key_attributes,
        // table_attributes.size());

        long start = System.currentTimeMillis();
        PartitionPlan result = local_search.generate(hints);
        this.last_elapsed_time = Math.round((System.currentTimeMillis() - start) / 1000);
        this.last_halt_reason = local_search.halt_reason;
        this.last_backtrack_count = local_search.getLastBackTrackCount();

        return (Pair.of(result, local_search.getBestVertex()));
View Full Code Here

TOP

Related Classes of edu.brown.designer.partitioners.plan.PartitionPlan

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.