Package edu.brown.utils

Examples of edu.brown.utils.ArgumentsParser


        LOG.info("Procedures Histogram:\n" + proc_histogram);
        return;
    }

    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(ArgumentsParser.PARAM_CATALOG, ArgumentsParser.PARAM_WORKLOAD_OUTPUT);
       
        List<File> workload_files = new ArrayList<File>();
        for (int i = 0, cnt = args.getOptParamCount(); i < cnt; i++) {
            File base_workload_path = new File(args.getOptParam(i));
            File base_directory = base_workload_path.getParentFile();
            String base_workload_name = base_workload_path.getName();
            if (base_workload_name.endsWith("*")) {
                base_workload_name = base_workload_name.substring(0, base_workload_name.length()-2);
            }
           
            workload_files.addAll(FileUtil.getFilesInDirectory(base_directory, base_workload_name));
            if (workload_files.isEmpty()) {
                LOG.fatal("No workload files starting with '" + base_workload_name + "' were found in '" + base_directory + "'");
                System.exit(1);
            }
        }
        Collections.sort(workload_files);
       
        File output_path = new File(args.getParam(ArgumentsParser.PARAM_WORKLOAD_OUTPUT));
        FileUtil.makeDirIfNotExists(output_path.getParent());
       
        int num_workloads = workload_files.size();
        assert(num_workloads > 0) : "No workloads specified";
        Workload workloads[] = new Workload[num_workloads];
View Full Code Here


            ));
        return (new_workload);
    }
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(
            ArgumentsParser.PARAM_CATALOG,
            ArgumentsParser.PARAM_WORKLOAD,
            ArgumentsParser.PARAM_WORKLOAD_OUTPUT,
            ArgumentsParser.PARAM_MAPPINGS
        );
        Integer intervals = args.getIntParam(ArgumentsParser.PARAM_DESIGNER_INTERVALS);
       
        LOG.info(String.format("Compressing workload based on %d partitions%s",
                 args.catalogContext.numberOfPartitions,
                 (intervals != null ? " over " + intervals + " intervals" : "")));
        LOG.info("BEFORE:\n" + args.workload.getProcedureHistogram());
       
        PartitionEstimator p_estimator = new PartitionEstimator(args.catalogContext);
        WorkloadSummarizer ws = new WorkloadSummarizer(args.catalog_db, p_estimator, args.param_mappings);
        if (intervals != null) ws.setIntervals(intervals);
        Workload new_workload = ws.process(args.workload);
        assert(new_workload != null);
        LOG.info("AFTER:\n" + new_workload.getProcedureHistogram());
       
        File output_path = args.getFileParam(ArgumentsParser.PARAM_WORKLOAD_OUTPUT);
        LOG.info("Saving compressed workload '" + output_path + "'");
        new_workload.save(output_path, args.catalog_db);
    }
View Full Code Here

   
    /**
     * @param args
     */
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        args.require(
            ArgumentsParser.PARAM_CATALOG,
            ArgumentsParser.PARAM_WORKLOAD
        );
        assert(VerifyWorkload.verify(args.catalog_db, args.workload));
        LOG.info("The workload " + args.workload + " is valid!");
View Full Code Here

        if (debug.val) LOG.debug("Processed " + line_ctr + " workload trace records for histogram\n" + h);
        return (h);
    }
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);
        assert(args != null);
        System.out.println(getProcedureHistogram(new File("/home/pavlo/Documents/H-Store/SVN-Brown/trunk/files/workloads/tpce.trace.gz")));
       
    }
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, ArgumentsParser.PARAM_DESIGNER_INTERVALS
        // ArgumentsParser.PARAM_DESIGNER_HINTS
        );
        assert (args.workload.getTransactionCount() > 0) : "No transactions were loaded from " + args.workload;

        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);
        }

        // 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...");
        }
        System.out.flush();

        int num_intervals = args.num_intervals; // getIntParam(ArgumentsParser.PARAM_DESIGNER_INTERVALS);
        TimeIntervalCostModel<SingleSitedCostModel> costmodel = new TimeIntervalCostModel<SingleSitedCostModel>(args.catalogContext, SingleSitedCostModel.class, num_intervals);
        if (args.hasParam(ArgumentsParser.PARAM_DESIGNER_HINTS))
            costmodel.applyDesignerHints(args.designer_hints);
        double cost = costmodel.estimateWorkloadCost(args.catalogContext, args.workload);

        Map<String, Object> m = new LinkedHashMap<String, Object>();
        m.put("PARTITIONS", args.catalogContext.numberOfPartitions);
View Full Code Here

        }
    } // CLASS
   
   
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs,
            ArgumentsParser.PARAM_CATALOG
        );
       
        ConflictSetCalculator calculator = new ConflictSetCalculator(args.catalog);
       
        // Procedures to exclude in ConflictGraph
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES)) {
            String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES);
            for (String procName : param.split(",")) {
                Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(procName);
                if (catalog_proc != null) {
                    calculator.ignoreProcedure(catalog_proc);
                } else {
                    LOG.warn("Invalid procedure name to exclude '" + procName + "'");
                }
            } // FOR
        }
       
        // Statements to exclude in ConflictGraph
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_STATEMENTS)) {
            String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_STATEMENTS);
            for (String name : param.split(",")) {
                String splits[] = name.split("\\.");
                if (splits.length != 2) {
                    LOG.warn("Invalid procedure name to exclude '" + name + "': " + Arrays.toString(splits));
                    continue;
                }
                Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(splits[0]);
                if (catalog_proc == null) {
                    LOG.warn("Invalid procedure name to exclude '" + name + "'");
                    continue;
                }
                   
                Statement catalog_stmt = catalog_proc.getStatements().getIgnoreCase(splits[1]);
                if (catalog_stmt != null) {
                    calculator.ignoreStatement(catalog_stmt);
                } else {
                    LOG.warn("Invalid statement name to exclude '" + name + "'");
                }
            } // FOR
        }
       
        calculator.process();
        DumpGraph graph = new DumpGraph(args.catalogContext);
       
        // If we have a Procedure to "focus" on, then we need to remove any edges
        // that don't involve that Procedure
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_FOCUS_PROCEDURE)) {
            String procName = args.getParam(ArgumentsParser.PARAM_CONFLICTS_FOCUS_PROCEDURE);
            Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(procName);
            if (catalog_proc != null) {
                if (graph.procXref.containsKey(catalog_proc)) {
                    Vertex vertices[] = graph.procXref.get(catalog_proc).toArray(new Vertex[0]);
                    LOG.debug("Remove Edges Without: " + Arrays.toString(vertices));
                    GraphUtil.removeEdgesWithoutVertex(graph, vertices);
                    GraphUtil.removeLoopEdges(graph);
                    GraphUtil.removeDisconnectedVertices(graph);
                }
            } else {
                LOG.warn("Invalid procedure name to focus '" + procName + "'");
            }
        }
       
        // Export!
        GraphvizExport<Vertex, Edge> gvx = new GraphvizExport<Vertex, Edge>(graph);
        gvx.setEdgeLabels(true);
       
        for (Vertex v : graph.getVertices()) {
            // Generate subgraphs based on procedure
            ProcedureTable procTbl = v.getCatalogItem();
            Procedure proc = procTbl.pair.getFirst();
            gvx.addSubgraph(proc.getName(), v);
        } // FOR
       
        String graphviz = gvx.export(args.catalog_type.name());
        if (!graphviz.isEmpty()) {
            String output = args.getOptParam(0);
            if (output == null) {
                output = args.catalog_type.name().toLowerCase() + "-conflicts.dot";
            }
            File path = new File(output);
            FileUtil.writeStringToFile(path, graphviz);
View Full Code Here

    /**
     * @param args
     */
    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs,
                ArgumentsParser.PARAM_CATALOG
        );
       
        ConflictSetCalculator calculator = new ConflictSetCalculator(args.catalog);
       
        // Procedures to exclude in ConflictGraph
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES)) {
            String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES);
            for (String procName : param.split(",")) {
                Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(procName);
                if (catalog_proc != null) {
                    calculator.ignoreProcedure(catalog_proc);
                } else {
                    LOG.warn("Invalid procedure name to exclude '" + procName + "'");
                }
            } // FOR
        }
       
        // Statements to exclude in ConflictGraph
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_STATEMENTS)) {
            String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_STATEMENTS);
            for (String name : param.split(",")) {
                String splits[] = name.split("\\.");
                if (splits.length != 2) {
                    LOG.warn("Invalid procedure name to exclude '" + name + "': " + Arrays.toString(splits));
                    continue;
                }
                Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(splits[0]);
                if (catalog_proc == null) {
                    LOG.warn("Invalid procedure name to exclude '" + name + "'");
                    continue;
                }
                   
                Statement catalog_stmt = catalog_proc.getStatements().getIgnoreCase(splits[1]);
                if (catalog_stmt != null) {
                    calculator.ignoreStatement(catalog_stmt);
                } else {
                    LOG.warn("Invalid statement name to exclude '" + name + "'");
                }
            } // FOR
        }
       
        calculator.process();
        ConflictGraph graph = new ConflictGraph(args.catalog_db);
       
        // If we have a Procedure to "focus" on, then we need to remove any edges
        // that don't involve that Procedure
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_FOCUS_PROCEDURE)) {
            String procName = args.getParam(ArgumentsParser.PARAM_CONFLICTS_FOCUS_PROCEDURE);
            Procedure catalog_proc = args.catalogContext.procedures.getIgnoreCase(procName);
            if (catalog_proc != null) {
                ConflictVertex v = graph.getVertex(catalog_proc);
                assert(v != null);
                GraphUtil.removeEdgesWithoutVertex(graph, v);
                GraphUtil.removeDisconnectedVertices(graph);
            } else {
                LOG.warn("Invalid procedure name to focus '" + procName + "'");
            }
        }
       
        // Export!
        GraphvizExport<ConflictVertex, ConflictEdge> gvx = new GraphvizExport<ConflictVertex, ConflictEdge>(graph);
        gvx.setEdgeLabels(true);
        String graphviz = gvx.export(args.catalog_type.name());
        if (!graphviz.isEmpty()) {
            String output = args.getOptParam(0);
            if (output == null) {
                output = args.catalog_type.name().toLowerCase() + "-conflicts.dot";
            }
            File path = new File(output);
            FileUtil.writeStringToFile(path, graphviz);
View Full Code Here

   
    /**
     * @param args
     */
    public static void main(final String[] vargs) throws Exception {
        final ArgumentsParser args = ArgumentsParser.load(vargs);
       
        //edu.uci.ics.jung.samples.TreeLayoutDemo.main(args);
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                DesignerVisualization gui = new DesignerVisualization(args);
View Full Code Here

     * Main!
     * @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_MAPPINGS
        );
       
        // Number of threads
        int num_threads = FeatureClusterer.DEFAULT_NUM_THREADS;
        if (args.hasIntParam(ArgumentsParser.PARAM_MARKOV_THREADS)) {
            num_threads = args.getIntParam(ArgumentsParser.PARAM_MARKOV_THREADS);
        }
       
        // Get the procedure we're suppose to investigate
        String proc_name = args.getOptParam(0);
        Procedure catalog_proc = args.catalog_db.getProcedures().getIgnoreCase(proc_name);
        assert(catalog_proc != null) : proc_name;
       
        // And our Weka data file
//        File arff_path = new File(args.getOptParam(1));
//        assert(arff_path.exists()) : arff_path.getAbsolutePath();
//        BufferedReader reader = new BufferedReader(new FileReader(arff_path));
//        Instances data = new Instances(reader);
//        reader.close();
//        data = new Instances(data, 0, args.workload.getTransactionCount());
       
        Instances data = null;
        {
            // Hopefully this will get garbage collected if we put it here...
            FeatureExtractor fextractor = new FeatureExtractor(args.catalogContext);
            Map<Procedure, FeatureSet> fsets = fextractor.calculate(args.workload);
            FeatureSet fset = fsets.get(catalog_proc);
            assert(fset != null) : "Failed to get FeatureSet for " + catalog_proc;
            data = fset.export(catalog_proc.getName());
        }
        assert(data != null);
        assert(args.workload.getTransactionCount() == data.numInstances());
       
        PartitionSet partitions = null;
        if (args.hasParam(ArgumentsParser.PARAM_WORKLOAD_RANDOM_PARTITIONS)) {
            PartitionEstimator p_estimator = new PartitionEstimator(args.catalogContext);
            final ObjectHistogram<Integer> h = new ObjectHistogram<Integer>();
            for (TransactionTrace txn_trace : args.workload.getTransactions()) {
                int base_partition = p_estimator.getBasePartition(txn_trace);
                h.put(base_partition);
            } // FOR
//            System.err.println("# OF PARTITIONS: " + h.getValueCount());
//            h.setKeepZeroEntries(true);
//            for (Integer p : CatalogUtil.getAllPartitionIds(args.catalog_db)) {
//                if (h.contains(p) == false) h.put(p, 0);
//            }
//            System.err.println(h);
//            System.exit(1);
//           
            partitions = new PartitionSet(h.values());
        } else {
            partitions = args.catalogContext.getAllPartitionIds();   
        }
        FeatureClusterer fclusterer = new FeatureClusterer(args.catalogContext,
                                                           catalog_proc,
                                                           args.workload,
                                                           partitions,
                                                           num_threads);
        // Update split configuration variables
        for (SplitType type : SplitType.values()) {
            String param_name = String.format("%s.%s", ArgumentsParser.PARAM_MARKOV_SPLIT, type.name());
            if (args.hasDoubleParam(param_name) == false) continue;
            double percentage = args.getDoubleParam(param_name);
            fclusterer.setSplitPercentage(type, percentage);
        } // FOR
        if (args.hasDoubleParam(ArgumentsParser.PARAM_MARKOV_TOPK)) {
            fclusterer.setAttributeTopK(args.getDoubleParam(ArgumentsParser.PARAM_MARKOV_TOPK));
        }
        if (args.hasIntParam(ArgumentsParser.PARAM_MARKOV_ROUNDS)) {
            fclusterer.setNumRounds(args.getIntParam(ArgumentsParser.PARAM_MARKOV_ROUNDS));
        }

//      MarkovAttributeSet aset = fclusterer.calculate(data);
       
        // HACK
View Full Code Here

        return (bytes);
    }

    public static void main(String[] vargs) throws Exception {
        ArgumentsParser args = ArgumentsParser.load(vargs);

        MemoryEstimator estimator = new MemoryEstimator(args.stats, new DefaultHasher(args.catalogContext));
        for (Table catalog_tbl : args.catalog_db.getTables()) {
            System.out.println(catalog_tbl + ": " + estimator.estimate(catalog_tbl, args.catalogContext.numberOfPartitions));
        }
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.