Package com.google.gxp.compiler.cli

Examples of com.google.gxp.compiler.cli.GxpcFlags$CommandLine


      topicsOpt).withOption(wordsOpt).withOption(topicSmOpt).withOption(maxIterOpt).withOption(numReducOpt)
        .withOption(overwriteOutput).withOption(helpOpt).create();
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
      String input = cmdLine.getValue(inputOpt).toString();
      String output = cmdLine.getValue(outputOpt).toString();
     
      int maxIterations = -1;
      if (cmdLine.hasOption(maxIterOpt)) {
        maxIterations = Integer.parseInt(cmdLine.getValue(maxIterOpt).toString());
      }
     
      int numReduceTasks = 2;
      if (cmdLine.hasOption(numReducOpt)) {
        numReduceTasks = Integer.parseInt(cmdLine.getValue(numReducOpt).toString());
      }
     
      int numTopics = 20;
      if (cmdLine.hasOption(topicsOpt)) {
        numTopics = Integer.parseInt(cmdLine.getValue(topicsOpt).toString());
      }
     
      int numWords = 20;
      if (cmdLine.hasOption(wordsOpt)) {
        numWords = Integer.parseInt(cmdLine.getValue(wordsOpt).toString());
      }
     
      if (cmdLine.hasOption(overwriteOutput)) {
        HadoopUtil.overwriteOutput(output);
      }
     
      double topicSmoothing = -1.0;
      if (cmdLine.hasOption(topicSmOpt)) {
        topicSmoothing = Double.parseDouble(cmdLine.getValue(maxIterOpt).toString());
      }
      if (topicSmoothing < 1) {
        topicSmoothing = 50.0 / numTopics;
      }
     
View Full Code Here


    new PropertyOption();
    Group allOptions = new GroupBuilder().withOption(isHelpOption).withOption(execOption).withOption(fileOption).withOption(grpOption).withOption(permOption).create();

    Parser parser = new Parser();
    parser.setGroup(allOptions);
    CommandLine cmdLine = null;

    try {
      cmdLine  = parser.parse(args);

    } catch (OptionException e1) {
      printErrString(null, System.err);
      System.exit(1);
    }
    // -e
    String execString = (String) cmdLine.getValue(execOption);
    // -f
    String fileName = (String) cmdLine.getValue(fileOption);
    // -h
    if (cmdLine.hasOption(isHelpOption)) {
      printErrString(null, System.out);
      System.exit(1);
    }

    if (execString != null && fileName != null) {
      printErrString("Please specify either -e or -f option.", System.err);
      System.exit(1);
    }

    // -p
    String perms = (String) cmdLine.getValue(permOption);
    if(perms != null){
      validatePermissions(ss, conf, perms);
    }

    // -g
    String grp = (String) cmdLine.getValue(grpOption);
    if(grp != null){
      conf.set(HowlConstants.HOWL_GROUP, grp);
    }

    if (execString != null) {
View Full Code Here

    cli.addOption("jobconf", false,
        "\"n1=v1,n2=v2,..\" Optional. Add or override a JobConf property.",
        "key=val");
    Parser parser = cli.createParser();
    try {
      CommandLine results = parser.parse(args);
      JobConf conf = new JobConf();
      if (results.hasOption("-conf")) {
        conf.addResource(new Path((String) results.getValue("-conf")));
      }
      if (results.hasOption("-input")) {
        conf.setInputPath(new Path((String) results.getValue("-input")));
      }
      if (results.hasOption("-output")) {
        conf.setOutputPath(new Path((String) results.getValue("-output")));
      }
      if (results.hasOption("-jar")) {
        conf.setJar((String) results.getValue("-jar"));
      }
      if (results.hasOption("-inputformat")) {
        setIsJavaRecordReader(conf, true);
        conf.setInputFormat(getClass(results, "-inputformat", conf,
                                     InputFormat.class));
      }
      if (results.hasOption("-javareader")) {
        setIsJavaRecordReader(conf, true);
      }
      if (results.hasOption("-map")) {
        setIsJavaMapper(conf, true);
        conf.setMapperClass(getClass(results, "-map", conf, Mapper.class));
      }
      if (results.hasOption("-partitioner")) {
        conf.setPartitionerClass(getClass(results, "-partitioner", conf,
                                          Partitioner.class));
      }
      if (results.hasOption("-reduce")) {
        setIsJavaReducer(conf, true);
        conf.setReducerClass(getClass(results, "-reduce", conf, Reducer.class));
      }
      if (results.hasOption("-reduces")) {
        conf.setNumReduceTasks(Integer.parseInt((String)
                                                results.getValue("-reduces")));
      }
      if (results.hasOption("-writer")) {
        setIsJavaRecordWriter(conf, true);
        conf.setOutputFormat(getClass(results, "-writer", conf,
                                      OutputFormat.class));
      }
      if (results.hasOption("-program")) {
        setExecutable(conf, (String) results.getValue("-program"));
      }
      if (results.hasOption("-jobconf")) {
        String options = (String)results.getValue("-jobconf");
        StringTokenizer tokenizer = new StringTokenizer(options, ",");
        while (tokenizer.hasMoreTokens()) {
          String keyVal = tokenizer.nextToken().trim();
          String[] keyValSplit = keyVal.split("=");
          conf.set(keyValSplit[0], keyValSplit[1]);
View Full Code Here

    msg("cmd=" + cmd);
    return cmd;
  }

  void parseArgv(){
    CommandLine cmdLine = null;
    try{
      cmdLine = parser.parse(argv_);
    }catch(Exception oe){
      LOG.error(oe.getMessage());
      exitUsage(argv_.length > 0 && "-info".equals(argv_[0]));
    }
   
    if (cmdLine != null){
      verbose_ =  cmdLine.hasOption("-verbose");
      detailedUsage_ = cmdLine.hasOption("-info");
      debug_ = cmdLine.hasOption("-debug")? debug_ + 1 : debug_;
     
      inputSpecs_.addAll(cmdLine.getValues("-input"));
      output_ = (String) cmdLine.getValue("-output");
     
      mapCmd_ = (String)cmdLine.getValue("-mapper");
      comCmd_ = (String)cmdLine.getValue("-combiner");
      redCmd_ = (String)cmdLine.getValue("-reducer");
     
      if(!cmdLine.getValues("-file").isEmpty()) {
        packageFiles_.addAll(cmdLine.getValues("-file"));
      }
        
      String fsName = (String)cmdLine.getValue("-dfs");
      if (null != fsName){
        LOG.warn("-dfs option is deprecated, please use -fs instead.");
        config_.set("fs.default.name", fsName);
      }
     
      additionalConfSpec_ = (String)cmdLine.getValue("-additionalconfspec");
      inputFormatSpec_ = (String)cmdLine.getValue("-inputformat");
      outputFormatSpec_ = (String)cmdLine.getValue("-outputformat");
      numReduceTasksSpec_ = (String)cmdLine.getValue("-numReduceTasks");
      partitionerSpec_ = (String)cmdLine.getValue("-partitioner");
      inReaderSpec_ = (String)cmdLine.getValue("-inputreader");
      mapDebugSpec_ = (String)cmdLine.getValue("-mapdebug");   
      reduceDebugSpec_ = (String)cmdLine.getValue("-reducedebug");
     
      List<String> car = cmdLine.getValues("-cacheArchive");
      if (null != car && !car.isEmpty()){
        LOG.warn("-cacheArchive option is deprecated, please use -archives instead.");
        for(String s : car){
          cacheArchives = (cacheArchives == null)?s :cacheArchives + "," + s; 
        }
      }

      List<String> caf = cmdLine.getValues("-cacheFile");
      if (null != caf && !caf.isEmpty()){
        LOG.warn("-cacheFile option is deprecated, please use -files instead.");
        for(String s : caf){
          cacheFiles = (cacheFiles == null)?s :cacheFiles + "," + s; 
        }
      }
     
      List<String> jobConfArgs = (List<String>)cmdLine.getValue(jobconf);
      List<String> envArgs = (List<String>)cmdLine.getValue(cmdenv);
     
      if (null != jobConfArgs && !jobConfArgs.isEmpty()){
        LOG.warn("-jobconf option is deprecated, please use -D instead.");
        for(String s : jobConfArgs){
          String []parts = s.split("=", 2);
View Full Code Here

    cli.addOption("jobconf", false,
        "\"n1=v1,n2=v2,..\" Optional. Add or override a JobConf property.",
        "key=val");
    Parser parser = cli.createParser();
    try {
      CommandLine results = parser.parse(args);
      JobConf conf = new JobConf();
      if (results.hasOption("-conf")) {
        conf.addResource(new Path((String) results.getValue("-conf")));
      }
      if (results.hasOption("-input")) {
        conf.setInputPath(new Path((String) results.getValue("-input")));
      }
      if (results.hasOption("-output")) {
        conf.setOutputPath(new Path((String) results.getValue("-output")));
      }
      if (results.hasOption("-jar")) {
        conf.setJar((String) results.getValue("-jar"));
      }
      if (results.hasOption("-inputformat")) {
        setIsJavaRecordReader(conf, true);
        conf.setInputFormat(getClass(results, "-inputformat", conf,
                                     InputFormat.class));
      }
      if (results.hasOption("-javareader")) {
        setIsJavaRecordReader(conf, true);
      }
      if (results.hasOption("-map")) {
        setIsJavaMapper(conf, true);
        conf.setMapperClass(getClass(results, "-map", conf, Mapper.class));
      }
      if (results.hasOption("-partitioner")) {
        conf.setPartitionerClass(getClass(results, "-partitioner", conf,
                                          Partitioner.class));
      }
      if (results.hasOption("-reduce")) {
        setIsJavaReducer(conf, true);
        conf.setReducerClass(getClass(results, "-reduce", conf, Reducer.class));
      }
      if (results.hasOption("-reduces")) {
        conf.setNumReduceTasks(Integer.parseInt((String)
                                                results.getValue("-reduces")));
      }
      if (results.hasOption("-writer")) {
        setIsJavaRecordWriter(conf, true);
        conf.setOutputFormat(getClass(results, "-writer", conf,
                                      OutputFormat.class));
      }
      if (results.hasOption("-program")) {
        setExecutable(conf, (String) results.getValue("-program"));
      }
      if (results.hasOption("-jobconf")) {
        String options = (String)results.getValue("-jobconf");
        StringTokenizer tokenizer = new StringTokenizer(options, ",");
        while (tokenizer.hasMoreTokens()) {
          String keyVal = tokenizer.nextToken().trim();
          String[] keyValSplit = keyVal.split("=");
          conf.set(keyValSplit[0], keyValSplit[1]);
View Full Code Here

      gBuilder = gBuilder.withOption(opt);
    }

    Group group = gBuilder.create();

    CommandLine cmdLine;
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      parser.setHelpOption(helpOpt);
      cmdLine = parser.parse(args);

    } catch (OptionException e) {
      log.error(e.getMessage());
      CommandLineUtil.printHelpWithGenericOptions(group, e);
      return null;
    }

    if (cmdLine.hasOption(helpOpt)) {
      CommandLineUtil.printHelpWithGenericOptions(group);
      return null;
    }

    try {
View Full Code Here

      outputOpt).withOption(maxHeapSizeOpt).withOption(numGroupsOpt).withOption(methodOpt).withOption(
      encodingOpt).withOption(helpOpt).withOption(treeCacheOpt).withOption(recordSplitterOpt).create();
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      Parameters params = new Parameters();
     
      if (cmdLine.hasOption(minSupportOpt)) {
        String minSupportString = (String) cmdLine.getValue(minSupportOpt);
        params.set("minSupport", minSupportString);
      }
      if (cmdLine.hasOption(maxHeapSizeOpt)) {
        String maxHeapSizeString = (String) cmdLine.getValue(maxHeapSizeOpt);
        params.set("maxHeapSize", maxHeapSizeString);
      }
      if (cmdLine.hasOption(numGroupsOpt)) {
        String numGroupsString = (String) cmdLine.getValue(numGroupsOpt);
        params.set("numGroups", numGroupsString);
      }
     
      if (cmdLine.hasOption(treeCacheOpt)) {
        String numTreeCacheString = (String) cmdLine.getValue(treeCacheOpt);
        params.set("treeCacheSize", numTreeCacheString);
      }
     
      if (cmdLine.hasOption(recordSplitterOpt)) {
        String patternString = (String) cmdLine.getValue(recordSplitterOpt);
        params.set("splitPattern", patternString);
      }
     
      String encoding = "UTF-8";
      if (cmdLine.hasOption(encodingOpt)) {
        encoding = (String) cmdLine.getValue(encodingOpt);
      }
      params.set("encoding", encoding);
      Path inputDir = new Path(cmdLine.getValue(inputDirOpt).toString());
      Path outputDir = new Path(cmdLine.getValue(outputOpt).toString());
     
      params.set("input", inputDir.toString());
      params.set("output", outputDir.toString());
     
      String classificationMethod = (String) cmdLine.getValue(methodOpt);
      if (classificationMethod.equalsIgnoreCase("sequential")) {
        runFPGrowth(params);
      } else if (classificationMethod.equalsIgnoreCase("mapreduce")) {
        HadoopUtil.overwriteOutput(outputDir);
        PFPGrowth.runPFPGrowth(params);
View Full Code Here

      outputDirOpt).withOption(parentOpt).withOption(helpOpt).create();
    try {
     
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
        CommandLineUtil.printHelp(group);
        return;
      }
     
      File parentDir = new File((String) cmdLine.getValue(parentOpt));
      File outputDir = new File((String) cmdLine.getValue(outputDirOpt));
      String analyzerName = (String) cmdLine.getValue(analyzerNameOpt);
      Charset charset = Charset.forName((String) cmdLine.getValue(charsetOpt));
      Analyzer analyzer;
      try {
        analyzer = Class.forName(analyzerName).asSubclass(Analyzer.class).newInstance();
      } catch (InstantiationException e) {
        analyzer = (Analyzer) Class.forName(analyzerName).getConstructor(Version.class).newInstance(Version.LUCENE_30);
View Full Code Here

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
      return false;
    }

    TrainLogistic.inputFile = getStringArgument(cmdLine, inputFile);
    TrainLogistic.outputFile = getStringArgument(cmdLine, outputFile);

    List<String> typeList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(types)) {
      typeList.add(x.toString());
    }

    List<String> predictorList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(predictors)) {
      predictorList.add(x.toString());
    }

    lmp = new LogisticModelParameters();
    lmp.setTargetVariable(getStringArgument(cmdLine, target));
View Full Code Here

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
      return false;
    }
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.cli.GxpcFlags$CommandLine

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.