Package edu.brown.utils

Examples of edu.brown.utils.ArgumentsParser


    /**
     * @param args
     */
    public static void main(String vargs[]) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG, ArgumentsParser.PARAM_MARKOV);
       
        File input_path = args.getFileParam(ArgumentsParser.PARAM_MARKOV);
        boolean full_output = true;
        boolean vldb_output = false;

        Set<Procedure> procedures = new HashSet<Procedure>();
        for (String proc_name : args.getOptParam(0).split(",")) {
            if (proc_name.equals("*")) {
                for (Procedure catalog_proc : args.catalog_db.getProcedures()) {
                    if (catalog_proc.getSystemproc()) continue;
                    procedures.add(catalog_proc);
                } // FOR
            } else {
                Procedure catalog_proc = args.catalog_db.getProcedures().getIgnoreCase(proc_name);
                assert(catalog_proc != null) : "Invalid procedure '" + proc_name + "'";
                procedures.add(catalog_proc);
            }
        } // FOR
        assert(procedures.size() > 0) : "No procedures";
       
        Map<Integer, MarkovGraphsContainer> m = MarkovGraphsContainerUtil.loadProcedures(args.catalogContext,
                                                                                         input_path, procedures);
        for (Procedure catalog_proc : procedures) {
            MarkovGraphsContainer markovs = null;
           
            if (m.containsKey(MarkovUtil.GLOBAL_MARKOV_CONTAINER_ID)) {
                markovs = m.get(MarkovUtil.GLOBAL_MARKOV_CONTAINER_ID);
            } else {
                assert(args.getOptParamCount() > 1) : "Missing partition argument";
                int partition = args.getIntOptParam(1);
                markovs = m.get(partition);
            }
           
            Map<Integer, MarkovGraph> markov_set = markovs.getAll(catalog_proc);
            if (markov_set == null || markov_set.isEmpty()) {
View Full Code Here


        if (debug.val) LOG.debug(String.format("Going to wait for %d MarkovGraphs to load", runnables.size()));
        ThreadUtil.runGlobalPool(runnables);
    }
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG,
                     ArgumentsParser.PARAM_MARKOV);
       
        Map<Integer, MarkovGraphsContainer> all_markovs = MarkovUtil.load(args.catalogContext,
                                                                          args.getFileParam(ArgumentsParser.PARAM_MARKOV));
        int cnt_invalid = 0;
        int cnt_total = 0;
        boolean save = true;
        for (Integer p : all_markovs.keySet()) {
            MarkovGraphsContainer m = all_markovs.get(p);
            LOG.info(String.format("[%s] Validating %d MarkovGraphs for partition %d", m.getClass().getSimpleName(), m.size(), p));
           
            for (Integer id : m.keySet()) {
                for (MarkovGraph markov : m.getAll(id).values()) {
                    boolean dump = false;
                    String before = MarkovUtil.exportGraphviz(markov, true, false, true, null).export(markov.getProcedure().getName());
                    try {
                        markov.calculateProbabilities(args.catalogContext.getAllPartitionIds());
                        markov.validate();
                        if (markov.getGraphId() == 10014) dump = true;
                    } catch (InvalidGraphElementException ex) {
                        cnt_invalid++;
                        LOG.error(String.format("[%d] %-16s - %s", markov.getGraphId(), markov.getProcedure().getName(), ex.getMessage()));
                        dump = true;
                        throw ex;
                    } finally {
                        if (dump) {
                            LOG.warn("BEFORE DUMPED: " + FileUtil.writeStringToFile("/tmp/before.dot", before));
                            LOG.warn("AFTER DUMPED: " + MarkovUtil.exportGraphviz(markov, true, false, true, null).writeToTempFile(markov.getProcedure()));
                        }
                    }
                    cnt_total++;
                }
            } // FOR
        }
        LOG.info("VALID: " + (cnt_total - cnt_invalid) + " / "+ cnt_total);
        if (save && cnt_invalid == 0) {
            MarkovGraphsContainerUtil.save(all_markovs, args.getFileParam(ArgumentsParser.PARAM_MARKOV));
        }
    }
View Full Code Here

    // ----------------------------------------------------------------------------
    // YE OLDE MAIN METHOD
    // ----------------------------------------------------------------------------

    public static void main(String vargs[]) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(
            ArgumentsParser.PARAM_CATALOG,
            ArgumentsParser.PARAM_WORKLOAD,
            ArgumentsParser.PARAM_MARKOV_OUTPUT
        );
        final PartitionEstimator p_estimator = new PartitionEstimator(args.catalogContext, args.hasher);
        Class<? extends MarkovGraphsContainer> containerClass = MarkovGraphsContainer.class;
       
        // Check whether we are generating the global graphs or the clustered versions
        Boolean global = args.getBooleanParam(ArgumentsParser.PARAM_MARKOV_GLOBAL);
        if (global != null && global == true) {
            containerClass = GlobalMarkovGraphsContainer.class;

        // TPCCMarkovGraphsContainer
        } else if (args.catalog_type == ProjectType.TPCC) {
            containerClass = TPCCMarkovGraphsContainer.class;
        // SEATSMarkovGraphsContainer
        } else if (args.catalog_type == ProjectType.SEATS) {
            containerClass = SEATSMarkovGraphsContainer.class;
        // AuctionMarkMarkovGraphsContainer
        } else if (args.catalog_type == ProjectType.AUCTIONMARK) {
            containerClass = AuctionMarkMarkovGraphsContainer.class;
        }
        assert(containerClass != null);
       
        Map<Integer, MarkovGraphsContainer> markovs_map = null;

        // Check whether we want to update an existing collection of MarkovGraphsContainers
        if (args.hasParam(ArgumentsParser.PARAM_MARKOV)) {
            File path = args.getFileParam(ArgumentsParser.PARAM_MARKOV);
            markovs_map = MarkovGraphsContainerUtil.load(args.catalogContext, path);
            MarkovGraphsContainerUtil.setHasher(markovs_map, p_estimator.getHasher());
        }
       
        if (markovs_map == null) {
            markovs_map = MarkovGraphsContainerUtil.createMarkovGraphsContainers(args.catalogContext,
                                                                                 args.workload,
                                                                                 p_estimator,
                                                                                 containerClass);
        } else {
            markovs_map = MarkovGraphsContainerUtil.createMarkovGraphsContainers(args.catalogContext,
                                                                                 args.workload,
                                                                                 p_estimator,
                                                                                 containerClass,
                                                                                 markovs_map);
        }
       
        // Save the graphs
        assert(markovs_map != null);
        File output = args.getFileParam(ArgumentsParser.PARAM_MARKOV_OUTPUT);
        LOG.info("Writing graphs out to " + output);
        MarkovGraphsContainerUtil.save(markovs_map, output);
    }
View Full Code Here

    /**
     * @param args
     */
    @SuppressWarnings("unchecked")
    public static void main(String vargs[]) throws Exception {
        final ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG,
                     ArgumentsParser.PARAM_MARKOV,
                     ArgumentsParser.PARAM_WORKLOAD,
                     ArgumentsParser.PARAM_MAPPINGS,
                     ArgumentsParser.PARAM_MARKOV_THRESHOLDS);
        HStoreConf.initArgumentsParser(args);
        final int num_partitions = args.catalogContext.numberOfPartitions;
        final int base_partition = (args.workload_base_partitions.size() == 1 ? CollectionUtil.first(args.workload_base_partitions) : HStoreConstants.NULL_PARTITION_ID);
        final int num_threads = ThreadUtil.getMaxGlobalThreads();
        final boolean stop_on_error = true;
        final boolean force_fullpath = true;
        final boolean force_regenerate = true;
        final boolean skip_processing = false;

        final ObjectHistogram<Procedure> total_h = new ObjectHistogram<Procedure>();
        final ObjectHistogram<Procedure> missed_h = new ObjectHistogram<Procedure>();
        final ObjectHistogram<Procedure> accurate_h = new ObjectHistogram<Procedure>();
        final ObjectHistogram<MarkovOptimization> optimizations_h = new ObjectHistogram<MarkovOptimization>();
        final ObjectHistogram<Penalty> penalties_h = new ObjectHistogram<Penalty>();
        final Map<Procedure, ObjectHistogram<MarkovOptimization>> proc_penalties_h = new ConcurrentHashMap<Procedure, ObjectHistogram<MarkovOptimization>>();

        final AtomicInteger total = new AtomicInteger(0);
        final AtomicInteger failures = new AtomicInteger(0);
        final List<Runnable> runnables = new ArrayList<Runnable>();
        final List<Thread> processing_threads = new ArrayList<Thread>();
        final AtomicInteger thread_finished = new AtomicInteger(0);

        // Only load the MarkovGraphs that we actually need
        final int num_transactions = args.workload.getTransactionCount();
        assert (num_transactions > 0) : "No TransactionTraces";
        final int marker = Math.max(1, (int) (num_transactions * 0.10));
        final Set<Procedure> procedures = args.workload.getProcedures(args.catalog_db);
        PartitionSet partitions = null;
        if (base_partition != HStoreConstants.NULL_PARTITION_ID) {
            partitions = new PartitionSet(base_partition);
        } else {
            partitions = args.catalogContext.getAllPartitionIds();
        }

        final File input_path = args.getFileParam(ArgumentsParser.PARAM_MARKOV);
        final Map<Integer, MarkovGraphsContainer> m = MarkovGraphsContainerUtil.load(args.catalogContext,
                                                                                     input_path, procedures, partitions);
        assert (m != null);
        final boolean global = m.containsKey(MarkovUtil.GLOBAL_MARKOV_CONTAINER_ID);
        final Map<Integer, MarkovGraphsContainer> thread_markovs[] = (Map<Integer, MarkovGraphsContainer>[]) new Map<?, ?>[num_threads];
View Full Code Here

        } // FOR
        return (fsets);
    }

    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(
            ArgumentsParser.PARAM_CATALOG,
            ArgumentsParser.PARAM_WORKLOAD,
            ArgumentsParser.PARAM_MAPPINGS
        );
       
View Full Code Here

     *
     * @param vargs
     * @throws Exception
     */
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG, ArgumentsParser.PARAM_WORKLOAD, ArgumentsParser.PARAM_PARTITION_PLAN);
        assert (args.workload.getTransactionCount() > 0) : "No transactions were loaded from " + args.workload_path;

        if (args.hasParam(ArgumentsParser.PARAM_CATALOG_HOSTS)) {
            ClusterConfiguration cc = new ClusterConfiguration(args.getParam(ArgumentsParser.PARAM_CATALOG_HOSTS));
            args.updateCatalog(FixCatalog.cloneCatalog(args.catalog, cc), null);
        }

        // Enable compact output
        final boolean table_output = (args.getOptParams().contains("table"));

        // If given a PartitionPlan, then update the catalog
        File pplan_path = new File(args.getParam(ArgumentsParser.PARAM_PARTITION_PLAN));
        PartitionPlan pplan = new PartitionPlan();
        pplan.load(pplan_path, args.catalogContext.database);
        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.catalogContext.database);

        System.out.println("Applied PartitionPlan '" + pplan_path + "' to catalog\n" + pplan);
        System.out.print(StringUtil.DOUBLE_LINE);
        // if (!table_output) {
        //
        // }
        // } else if (!table_output) {
        // System.err.println("PartitionPlan file '" + pplan_path +
        // "' does not exist. Ignoring...");
        // }
        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 + "'");
        }
View Full Code Here

    // ----------------------------------------------------------------------------
    // YE OLD MAIN METHOD
    // ----------------------------------------------------------------------------
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs,
            ArgumentsParser.PARAM_CATALOG
        );
        int site_id = args.getIntOptParam(0);
       
        HStoreConf hstore_conf = HStoreConf.initArgumentsParser(args);
        hstore_conf.site.cpu_affinity = false;
        hstore_conf.site.status_enable = false;
       
View Full Code Here

        return (gh);
    }
   
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
       
        File csv_path = new File(args.getOptParam(0));
        File output_path = new File(args.getOptParam(1));
       
        GenerateHistograms gh = GenerateHistograms.generate(csv_path);
       
        Map<String, Object> m = new ListOrderedMap<String, Object>();
        m.put("Airport Codes", gh.flights_per_airport.size());
View Full Code Here

    private static double rad2deg(double rad) {
        return (rad * 180.0 / Math.PI);
    }
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG);
       
        File data_dir = new File(args.getOptParam(0));
        assert(data_dir.exists());
       
        Table catalog_tbl = args.catalog_db.getTables().get(SEATSConstants.TABLENAME_AIRPORT);
        assert(catalog_tbl != null);
        File f = new File(data_dir.getAbsolutePath() + File.separator + "table." + catalog_tbl.getName().toLowerCase() + ".csv");
View Full Code Here

TOP

Related Classes of edu.brown.utils.ArgumentsParser

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.