Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.Path.toUri()


public class FileInfosDatasetTest extends MahoutTestCase {

  public void testRanges() throws IOException {
    Path inpath = new Path("target/test-classes/wdbc");
    FileSystem fs = FileSystem.get(inpath.toUri(), new Configuration());
   
    DataSet dataset = FileInfoParser.parseFile(fs, inpath);
    DataSet.initialize(dataset);

    DataLine dl = new DataLine();
View Full Code Here


      // random descriptions
      Object[][] descriptions = randomDescriptions(descriptors);

      // random dataset
      Path inpath = new Path("input");
      FileSystem fs = FileSystem.get(inpath.toUri(), new Configuration());
      if (fs.exists(inpath)) {
        fs.delete(inpath, true);
      }

      randomDataset(fs, inpath, descriptors, descriptions);
View Full Code Here

  private HadoopUtil() { }
 
  public static void overwriteOutput(String output) throws IOException {
    Configuration conf = new JobConf(KMeansDriver.class);
    Path outPath = new Path(output);
    FileSystem fs = FileSystem.get(outPath.toUri(), conf);
    if (fs.exists(outPath)) {
      log.warn("Deleting {}", outPath);
      fs.delete(outPath, true);
    }
    log.warn("Creating dir {}", outPath);
View Full Code Here

   * @throws RuntimeException
   *           if the data could not be loaded
   */
  private static Data loadData(Configuration conf, Dataset dataset) throws IOException {
    Path dataPath = Builder.getDistributedCacheFile(conf, 1);
    FileSystem fs = FileSystem.get(dataPath.toUri(), conf);
    return DataLoader.loadData(dataset, fs, dataPath);
  }
 
  @Override
  protected void setup(Context context) throws IOException, InterruptedException {
View Full Code Here

    SequenceFile.Writer inputVectorPathWriter = new SequenceFile.Writer(fs,
            conf, inputVectorPath, NullWritable.class, VectorWritable.class);
    VectorWritable inputVW = new VectorWritable(v);
    inputVectorPathWriter.append(NullWritable.get(), inputVW);
    inputVectorPathWriter.close();
    URI ivpURI = inputVectorPath.toUri();
    DistributedCache.setCacheFiles(new URI[] {ivpURI}, conf);
    fs.deleteOnExit(inputVectorPath);

    conf.set(INPUT_VECTOR, ivpURI.toString());
    conf.setBoolean(IS_SPARSE_OUTPUT, !(v instanceof DenseVector));
View Full Code Here

    for (int k = 0; k < points.size(); k++) {
      System.out.println("testKFuzzyKMeansMRJob k= " + k);
      // pick k initial cluster centers at random
      JobConf job = new JobConf(FuzzyKMeansDriver.class);
      Path path = new Path("testdata/clusters");
      FileSystem fs = FileSystem.get(path.toUri(), job);
      if (fs.exists(path)) {
        fs.delete(path, true);
      }
     
      testData = new File("testdata/clusters");
View Full Code Here

       
      }
      writer.close();
     
      Path outPath = new Path("output");
      fs = FileSystem.get(outPath.toUri(), conf);
      if (fs.exists(outPath)) {
        fs.delete(outPath, true);
      }
      fs.mkdirs(outPath);
      // now run the Job
View Full Code Here

    for (int k = 1; k < points.size(); k++) {
      System.out.println("testKMeansMRJob k= " + k);
      // pick k initial cluster centers at random
      JobConf job = new JobConf(KMeansDriver.class);
      Path path = new Path("testdata/clusters/part-00000");
      FileSystem fs = FileSystem.get(path.toUri(), job);
      SequenceFile.Writer writer = new SequenceFile.Writer(fs, job, path, Text.class, Cluster.class);
     
      for (int i = 0; i < k + 1; i++) {
        Vector vec = points.get(i).get();
       
View Full Code Here

   * @throws RuntimeException
   *           if the data could not be loaded
   */
  private static Data loadData(JobConf conf, Dataset dataset) throws IOException {
    Path dataPath = Builder.getDistributedCacheFile(conf, 1);
    FileSystem fs = FileSystem.get(dataPath.toUri(), conf);
    return DataLoader.loadData(dataset, fs, dataPath);
  }
 
  @Override
  public void configure(JobConf conf) {
View Full Code Here

    // now run the Canopy Driver
    CanopyDriver.runJob("testdata", "output/canopies", ManhattanDistanceMeasure.class.getName(), 3.1, 2.1);
   
    // verify output from sequence file
    Path path = new Path("output/canopies/part-00000");
    FileSystem fs = FileSystem.get(path.toUri(), job);
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, job);
    Text key = new Text();
    Canopy canopy = new Canopy();
    assertTrue("more to come", reader.next(key, canopy));
    assertEquals("1st key", "C0", key.toString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.