Package org.nebulaframework.benchmark.scimark2

Examples of org.nebulaframework.benchmark.scimark2.commandline


    .withOption(substringOpt).withOption(countOpt).withOption(helpOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
       
        printHelp(group);
        return;
      }
     
      if (cmdLine.hasOption(seqOpt)) {
        Path path = new Path(cmdLine.getValue(seqOpt).toString());
        JobClient client = new JobClient();
        JobConf conf = new JobConf(Job.class);
        client.setConf(conf);
        FileSystem fs = FileSystem.get(path.toUri(), conf);
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
       
        Writer writer;
        if (cmdLine.hasOption(outputOpt)) {
          writer = new FileWriter(cmdLine.getValue(outputOpt).toString());
        } else {
          writer = new OutputStreamWriter(System.out);
        }
        writer.append("Input Path: ").append(String.valueOf(path)).append('\n');
       
        int sub = Integer.MAX_VALUE;
        if (cmdLine.hasOption(substringOpt)) {
          sub = Integer.parseInt(cmdLine.getValue(substringOpt).toString());
        }
        boolean countOnly = cmdLine.hasOption(countOpt);
        Writable key = (Writable) reader.getKeyClass().newInstance();
        Writable value = (Writable) reader.getValueClass().newInstance();
        writer.append("Key class: ").append(String.valueOf(reader.getKeyClass())).append(" Value Class: ")
        .append(String.valueOf(value.getClass())).append('\n');
        writer.flush();
        long count = 0;
        if (countOnly == false) {
          while (reader.next(key, value)) {
            writer.append("Key: ").append(String.valueOf(key));
            String str = value.toString();
            writer.append(": Value: ").append(str.length() > sub ? str.substring(0, sub) : str);
            writer.write('\n');
            writer.flush();
            count++;
          }
          writer.append("Count: ").append(String.valueOf(count)).append('\n');
        } else {
          while (reader.next(key, value)) {
            count++;
          }
          writer.append("Count: ").append(String.valueOf(count)).append('\n');
        }
        writer.flush();
        if (cmdLine.hasOption(outputOpt)) {
          writer.close();
        }
      }
     
    } catch (OptionException e) {
View Full Code Here


        .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();
     
      job.runJob(input, output, new BayesParameters(1));
    } catch (OptionException e) {
      log.error(e.getMessage());
      CommandLineUtil.printHelp(group);
View Full Code Here

      printKeyOpt).create();
   
    try {
      Parser parser = new Parser();
      parser.setGroup(group);
      CommandLine cmdLine = parser.parse(args);
     
      if (cmdLine.hasOption(helpOpt)) {
       
        printHelp(group);
        return;
      }
     
      if (cmdLine.hasOption(seqOpt)) {
        Path path = new Path(cmdLine.getValue(seqOpt).toString());
        System.out.println("Input Path: " + path);
        JobClient client = new JobClient();
        JobConf conf = new JobConf(Job.class);
        client.setConf(conf);
       
        FileSystem fs = FileSystem.get(path.toUri(), conf);
       
        String dictionaryType = "text";
        if (cmdLine.hasOption(dictTypeOpt)) {
          dictionaryType = cmdLine.getValue(dictTypeOpt).toString();
        }
       
        String[] dictionary = null;
        if (cmdLine.hasOption(dictOpt)) {
          if (dictionaryType.equals("text")) {
            dictionary = VectorHelper.loadTermDictionary(new File(cmdLine.getValue(dictOpt).toString()));
          } else if (dictionaryType.equals("sequencefile")) {
            dictionary = VectorHelper.loadTermDictionary(conf, fs, cmdLine.getValue(dictOpt).toString());
          } else {
            throw new OptionException(dictTypeOpt);
          }
        }
        boolean useJSON = cmdLine.hasOption(centroidJSonOpt);
       
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
        SequenceFileVectorIterable vectorIterable = new SequenceFileVectorIterable(reader, cmdLine
            .hasOption(vectorAsKeyOpt));
        Writer writer;
        if (cmdLine.hasOption(outputOpt)) {
          writer = new FileWriter(cmdLine.getValue(outputOpt).toString());
        } else {
          writer = new OutputStreamWriter(System.out);
        }
        boolean printKey = cmdLine.hasOption(printKeyOpt);
        SeqFileIterator iterator = (SeqFileIterator) vectorIterable.iterator();
        int i = 0;
        while (iterator.hasNext()) {
          Vector vector = iterator.next();
          if (printKey) {
            writer.write(iterator.key().toString());
            writer.write("\t");
          }
          String fmtStr = useJSON ? vector.asFormatString() : VectorHelper.vectorToString(vector, dictionary);
          writer.write(fmtStr);
          writer.write('\n');
          i++;
        }
        writer.flush();
        if (cmdLine.hasOption(outputOpt)) {
          writer.close();
        }
        System.err.println("Dumped " + i + " Vectors");
      }
     
View Full Code Here

      measureClassOpt).withOption(convergenceDeltaOpt).withOption(maxIterationsOpt)
        .withOption(vectorClassOpt).withOption(t1Opt).withOption(t2Opt).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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      String measureClass = cmdLine.getValue(measureClassOpt,
        "org.apache.mahout.common.distance.EuclideanDistanceMeasure").toString();
      double t1 = Double.parseDouble(cmdLine.getValue(t1Opt, "80").toString());
      double t2 = Double.parseDouble(cmdLine.getValue(t2Opt, "55").toString());
      double convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt, "0.5").toString());
      int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterationsOpt, 10).toString());
      // String className = cmdLine.getValue(vectorClassOpt,
      // "org.apache.mahout.math.RandomAccessSparseVector").toString();
      // Class<? extends Vector> vectorClass = Class.forName(className).asSubclass(Vector.class);
     
      runJob(input, output, measureClass, t1, t2, convergenceDelta, maxIterations);
View Full Code Here

        .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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      runJob(input, output);
    } catch (OptionException e) {
      InputDriver.LOG.error("Exception parsing command line: ", e);
      CommandLineUtil.printHelp(group);
    }
View Full Code Here

      vectorOpt).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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      String vectorClassName = cmdLine.getValue(vectorOpt,
         "org.apache.mahout.math.RandomAccessSparseVector").toString();
      runJob(input, output, vectorClassName);
    } catch (OptionException e) {
      InputDriver.LOG.error("Exception parsing command line: ", e);
      CommandLineUtil.printHelp(group);
View Full Code Here

        .withOption(maxIterOpt).withOption(threshold2Opt).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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      String measureClassName = cmdLine.getValue(modelOpt,
        "org.apache.mahout.common.distance.EuclideanDistanceMeasure").toString();
      double t1 = Double.parseDouble(cmdLine.getValue(threshold1Opt, "47.6").toString());
      double t2 = Double.parseDouble(cmdLine.getValue(threshold2Opt, "1").toString());
      double convergenceDelta = Double.parseDouble(cmdLine.getValue(convergenceDeltaOpt, "0.5").toString());
      int maxIterations = Integer.parseInt(cmdLine.getValue(maxIterOpt, "10").toString());
      runJob(input, output, measureClassName, t1, t2, convergenceDelta, maxIterations);
    } catch (OptionException e) {
      log.error("Exception parsing command line: ", e);
      CommandLineUtil.printHelp(group);
    }
View Full Code Here

        .withOption(t1Opt).withOption(t2Opt).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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      String measureClass = cmdLine.getValue(measureClassOpt,
        "org.apache.mahout.common.distance.EuclideanDistanceMeasure").toString();
     
      // String className = cmdLine.getValue(vectorClassOpt,
      // "org.apache.mahout.math.RandomAccessSparseVector").toString();
      // Class<? extends Vector> vectorClass = Class.forName(className).asSubclass(Vector.class);
      double t1 = Double.parseDouble(cmdLine.getValue(t1Opt, "80").toString());
      double t2 = Double.parseDouble(cmdLine.getValue(t2Opt, "55").toString());
     
      runJob(input, output, measureClass, t1, t2);
    } catch (OptionException e) {
      Job.log.error("Exception", e);
      CommandLineUtil.printHelp(group);
View Full Code Here

        .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, "testdata").toString();
      String output = cmdLine.getValue(outputOpt, "output").toString();
      runJob(input, output);
    } catch (OptionException e) {
      OutputDriver.LOG.error("Exception parsing command line: ", e);
      CommandLineUtil.printHelp(group);
    }
View Full Code Here

    Group group = gbuilder.withName("Options").withOption(dumpFileOpt).withOption(outputDirOpt).withOption(
      chunkSizeOpt).withOption(numChunksOpt).withOption(s3IdOpt).withOption(s3SecretOpt).create();
   
    Parser parser = new Parser();
    parser.setGroup(group);
    CommandLine cmdLine;
    try {
      cmdLine = parser.parse(args);
    } catch (OptionException e) {
      log.error("Error while parsing options", e);
      CommandLineUtil.printHelp(group);
      return;
    }
   
    Configuration conf = new Configuration();
    String dumpFilePath = (String) cmdLine.getValue(dumpFileOpt);
    String outputDirPath = (String) cmdLine.getValue(outputDirOpt);
   
    if (cmdLine.hasOption(s3IdOpt)) {
      String id = (String) cmdLine.getValue(s3IdOpt);
      conf.set("fs.s3n.awsAccessKeyId", id);
      conf.set("fs.s3.awsAccessKeyId", id);
    }
    if (cmdLine.hasOption(s3SecretOpt)) {
      String secret = (String) cmdLine.getValue(s3SecretOpt);
      conf.set("fs.s3n.awsSecretAccessKey", secret);
      conf.set("fs.s3.awsSecretAccessKey", secret);
    }
    // do not compute crc file when using local FS
    conf.set("fs.file.impl", "org.apache.hadoop.fs.RawLocalFileSystem");
    FileSystem fs = FileSystem.get(URI.create(outputDirPath), conf);
   
    int chunkSize = 1024 * 1024 * Integer.parseInt((String) cmdLine.getValue(chunkSizeOpt));
   
    int numChunks = Integer.MAX_VALUE;
    if (cmdLine.hasOption(numChunksOpt)) {
      numChunks = Integer.parseInt((String) cmdLine.getValue(numChunksOpt));
    }
   
    String header = "<mediawiki xmlns=\"http://www.mediawiki.org/xml/export-0.3/\" "
                    + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
                    + "xsi:schemaLocation=\"http://www.mediawiki.org/xml/export-0.3/ "
View Full Code Here

TOP

Related Classes of org.nebulaframework.benchmark.scimark2.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.