Example usage for org.apache.hadoop.mapreduce.lib.input FileInputFormat addInputPath

List of usage examples for org.apache.hadoop.mapreduce.lib.input FileInputFormat addInputPath

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.lib.input FileInputFormat addInputPath.

Prototype

public static void addInputPath(Job job, Path path) throws IOException 

Source Link

Document

Add a Path to the list of inputs for the map-reduce job.

Usage

From source file:cp_c.CP_C.java

public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    Job job = Job.getInstance(conf, "word count");
    job.setJarByClass(CP_C.class);

    job.setMapperClass(TokenizerMapper.class);
    job.setReducerClass(IntSumReducer.class);

    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(Text.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    System.exit(job.waitForCompletion(true) ? 0 : 1);
}

From source file:crunch.MaxTemperature.java

License:Apache License

  public static void main(String[] args) throws Exception {
  if (args.length != 2) {
    System.err.println("Usage: MaxTemperature <input path> <output path>");
    System.exit(-1);/*from  ww  w .  j a  v  a2s.  c o m*/
  }
    
  Job job = new Job();        // XXX
  job.setJarByClass(MaxTemperature.class); // XXX
  job.setJobName("Max temperature");

  FileInputFormat.addInputPath(job, new Path(args[0])); // XXX
  FileOutputFormat.setOutputPath(job, new Path(args[1])); // XXX
    
  job.setMapperClass(MaxTemperatureMapper.class); 
  job.setReducerClass(MaxTemperatureReducer.class);

  job.setOutputKeyClass(Text.class); // XXX sets both Map and Reduce Key class.  For only map setMapOutputKeyClass()
  job.setOutputValueClass(IntWritable.class); // XXX and setMapOutputValueClass()
    
  System.exit(job.waitForCompletion(true) ? 0 : 1); // XXX
}

From source file:crunch.MaxTemperature.java

License:Apache License

  public static void main(String[] args) throws Exception {
  if (args.length != 2) {
    System.err.println("Usage: MaxTemperatureWithCombiner <input path> " +
        "<output path>");
    System.exit(-1);//from   w  w w.  j  a v a  2  s.  co  m
  }
    
  Job job = new Job();
  job.setJarByClass(MaxTemperatureWithCombiner.class);
  job.setJobName("Max temperature");

  FileInputFormat.addInputPath(job, new Path(args[0]));
  FileOutputFormat.setOutputPath(job, new Path(args[1]));
    
  job.setMapperClass(MaxTemperatureMapper.class);
  /*[*/job.setCombinerClass(MaxTemperatureReducer.class)/*]*/;
  job.setReducerClass(MaxTemperatureReducer.class);

  job.setOutputKeyClass(Text.class);
  job.setOutputValueClass(IntWritable.class);
    
  System.exit(job.waitForCompletion(true) ? 0 : 1);
}

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws IOException {
        if (args.length != 2) {
            System.err.println("Usage: OldMaxTemperature <input path> <output path>");
            System.exit(-1);/*from www. ja  va2s  . c  o  m*/
        }

        /*[*/JobConf conf = new JobConf(OldMaxTemperature.class);
        /*]*/
        /*[*/conf/*]*/.setJobName("Max temperature");

        FileInputFormat.addInputPath(/*[*/conf/*]*/, new Path(args[0]));
        FileOutputFormat.setOutputPath(/*[*/conf/*]*/, new Path(args[1]));

        /*[*/conf/*]*/.setMapperClass(OldMaxTemperatureMapper.class);
        /*[*/conf/*]*/.setReducerClass(OldMaxTemperatureReducer.class);

        /*[*/conf/*]*/.setOutputKeyClass(Text.class);
        /*[*/conf/*]*/.setOutputValueClass(IntWritable.class);

        /*[*/JobClient.runJob(conf);/*]*/
    }

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws IOException {
        if (args.length != 2) {
            System.err.println("Usage: MaxTemperature <input path> <output path>");
            System.exit(-1);//from   w ww  .  jav a  2 s  . com
        }

        JobConf conf = new JobConf(MaxTemperature.class);
        conf.setJobName("Max temperature");

        FileInputFormat.addInputPath(conf, new Path(args[0]));
        FileOutputFormat.setOutputPath(conf, new Path(args[1]));

        conf.setMapperClass(MaxTemperatureMapper.class);
        conf.setReducerClass(MaxTemperatureReducer.class);

        conf.setOutputKeyClass(Text.class);
        conf.setOutputValueClass(IntWritable.class);

        JobClient.runJob(conf);
    }

From source file:crunch.MaxTemperature.java

License:Apache License

  public static void main(String[] args) throws IOException {
  if (args.length != 2) {
    System.err.println("Usage: MaxTemperatureWithCombiner <input path> " +
          "<output path>");
    System.exit(-1);/*from ww w.j a v  a 2  s  .c o  m*/
  }
    
  JobConf conf = new JobConf(MaxTemperatureWithCombiner.class);
  conf.setJobName("Max temperature");

  FileInputFormat.addInputPath(conf, new Path(args[0]));
  FileOutputFormat.setOutputPath(conf, new Path(args[1]));
    
  conf.setMapperClass(MaxTemperatureMapper.class);
  /*[*/conf.setCombinerClass(MaxTemperatureReducer.class)/*]*/;
  conf.setReducerClass(MaxTemperatureReducer.class);

  conf.setOutputKeyClass(Text.class);
  conf.setOutputValueClass(IntWritable.class);

  JobClient.runJob(conf);
}

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            System.err.println("Usage: MaxTemperatureWithCompression <input path> " + "<output path>");
            System.exit(-1);// ww  w. j a  v  a 2 s.c  o  m
        }

        Job job = new Job();
        job.setJarByClass(MaxTemperature.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        /*[*/FileOutputFormat.setCompressOutput(job, true);
        FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);/*]*/

        job.setMapperClass(MaxTemperatureMapper.class);
        job.setCombinerClass(MaxTemperatureReducer.class);
        job.setReducerClass(MaxTemperatureReducer.class);

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            System.err.println("Usage: MaxTemperatureWithMapOutputCompression " + "<input path> <output path>");
            System.exit(-1);//from  ww  w. j av a 2  s. c  o m
        }

        // vv MaxTemperatureWithMapOutputCompression
        Configuration conf = new Configuration();
        conf.setBoolean("mapred.compress.map.output", true);
        conf.setClass("mapred.map.output.compression.codec", GzipCodec.class, CompressionCodec.class);
        Job job = new Job(conf);
        // ^^ MaxTemperatureWithMapOutputCompression
        job.setJarByClass(MaxTemperature.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        job.setMapperClass(MaxTemperatureMapper.class);
        job.setCombinerClass(MaxTemperatureReducer.class);
        job.setReducerClass(MaxTemperatureReducer.class);

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws IOException {
        if (args.length != 2) {
            System.err.println("Usage: MaxTemperatureWithCompression <input path> " + "<output path>");
            System.exit(-1);//from  ww w  .  ja  v a2 s  .c  om
        }

        JobConf conf = new JobConf(MaxTemperatureWithCompression.class);
        conf.setJobName("Max temperature with output compression");

        FileInputFormat.addInputPath(conf, new Path(args[0]));
        FileOutputFormat.setOutputPath(conf, new Path(args[1]));

        conf.setOutputKeyClass(Text.class);
        conf.setOutputValueClass(IntWritable.class);

        /*[*/FileOutputFormat.setCompressOutput(conf, true);
        FileOutputFormat.setOutputCompressorClass(conf, GzipCodec.class);/*]*/

        conf.setMapperClass(MaxTemperatureMapper.class);
        conf.setCombinerClass(MaxTemperatureReducer.class);
        conf.setReducerClass(MaxTemperatureReducer.class);

        JobClient.runJob(conf);
    }

From source file:crunch.MaxTemperature.java

License:Apache License

public static void main(String[] args) throws IOException {
        if (args.length != 2) {
            System.err.println("Usage: MaxTemperatureWithMapOutputCompression " + "<input path> <output path>");
            System.exit(-1);/*w w  w . j a v  a 2  s  .c om*/
        }

        JobConf conf = new JobConf(MaxTemperatureWithCompression.class);
        conf.setJobName("Max temperature with map output compression");

        FileInputFormat.addInputPath(conf, new Path(args[0]));
        FileOutputFormat.setOutputPath(conf, new Path(args[1]));

        conf.setOutputKeyClass(Text.class);
        conf.setOutputValueClass(IntWritable.class);

        // vv OldMaxTemperatureWithMapOutputCompression
        conf.setCompressMapOutput(true);
        conf.setMapOutputCompressorClass(GzipCodec.class);
        // ^^ OldMaxTemperatureWithMapOutputCompression

        conf.setMapperClass(MaxTemperatureMapper.class);
        conf.setCombinerClass(MaxTemperatureReducer.class);
        conf.setReducerClass(MaxTemperatureReducer.class);

        JobClient.runJob(conf);
    }