List of usage examples for org.apache.hadoop.util GenericOptionsParser getRemainingArgs
public String[] getRemainingArgs()
From source file:WordCount_SiCombiner.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); GenericOptionsParser parser = new GenericOptionsParser(conf, args); String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 2) { System.err.println("Usage: wordcount <in> <out>"); System.exit(2);/* w w w . j av a 2 s .com*/ } Job job = new Job(conf, "word count"); job.setJarByClass(WordCount_SiCombiner.class); job.setMapperClass(TokenizerMapper.class); job.setCombinerClass(IntSumReducer.class); // disable combiner // job.setCombinerClass(IntSumReducer.class); job.setPartitionerClass(WordPartition.class); job.setNumReduceTasks(5); job.setReducerClass(IntSumReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); }
From source file:WordCount_PerMapTally.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); GenericOptionsParser parser = new GenericOptionsParser(conf, args); String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 2) { System.err.println("Usage: wordcount <in> <out>"); System.exit(2);/*from w w w . j a va 2 s .c o m*/ } Job job = new Job(conf, "word count"); job.setJarByClass(WordCount_PerMapTally.class); job.setMapperClass(TokenizerMapper.class); // disable combiner // job.setCombinerClass(IntSumReducer.class); job.setPartitionerClass(WordPartitioner.class); job.setNumReduceTasks(5); job.setReducerClass(IntSumReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); }
From source file:WordCount_NoCombiner.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); GenericOptionsParser parser = new GenericOptionsParser(conf, args); String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 2) { System.err.println("Usage: wordcount <in> <out>"); System.exit(2);/*from w ww. j a v a 2 s .c o m*/ } Job job = new Job(conf, "word count"); job.setJarByClass(WordCount_NoCombiner.class); job.setMapperClass(TokenizerMapper.class); // delete this line to disable combining // job.setCombinerClass(IntSumReducer.class); job.setPartitionerClass(WordPartitioner.class); job.setNumReduceTasks(5); job.setReducerClass(IntSumReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); }
From source file:WordCount_PerTaskTally.java
License:Apache License
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); GenericOptionsParser parser = new GenericOptionsParser(conf, args); String[] otherArgs = parser.getRemainingArgs(); if (otherArgs.length != 2) { System.err.println("Usage: wordcount <in> <out>"); System.exit(2);/*from w ww . j a v a 2 s . co m*/ } Job job = new Job(conf, "word count"); job.setJarByClass(WordCount_PerTaskTally.class); job.setMapperClass(TokenizerMapper.class); // disable combiner // job.setCombinerClass(IntSumReducer.class); job.setPartitionerClass(WordPartitioner.class); job.setNumReduceTasks(5); job.setReducerClass(IntSumReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); System.exit(job.waitForCompletion(true) ? 0 : 1); }
From source file:com.alectenharmsel.hadoop.qa.LineCount.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parse = new GenericOptionsParser(new Configuration(), args); Configuration conf = parse.getConfiguration(); String[] remainingArgs = parse.getRemainingArgs(); if (remainingArgs.length != 2) { System.err.println("Usage: LineCount <input> <output>"); System.exit(-1);//w w w .j av a 2 s .c o m } Job job = Job.getInstance(conf, "LineCount"); job.setJarByClass(LineCount.class); job.setMapperClass(Map.class); job.setCombinerClass(Reduce.class); job.setReducerClass(Reduce.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); FileInputFormat.addInputPath(job, new Path(remainingArgs[0])); FileOutputFormat.setOutputPath(job, new Path(remainingArgs[1])); boolean success = job.waitForCompletion(true); int res = success ? 0 : 1; System.exit(res); }
From source file:com.alectenharmsel.research.FileCombine.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parse = new GenericOptionsParser(new Configuration(), args); Configuration conf = parse.getConfiguration(); int res = ToolRunner.run(conf, new FileCombine(), parse.getRemainingArgs()); System.exit(res);/* ww w . jav a 2 s .c om*/ }
From source file:com.alectenharmsel.research.hadoop.CodeTokenizer.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parse = new GenericOptionsParser(new Configuration(), args); Configuration conf = parse.getConfiguration(); int res = ToolRunner.run(conf, new CodeTokenizer(), parse.getRemainingArgs()); System.exit(res);/* w ww . j ava 2 s . c o m*/ }
From source file:com.alectenharmsel.research.hadoop.LcCounters.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parse = new GenericOptionsParser(new Configuration(), args); Configuration conf = parse.getConfiguration(); String[] remainingArgs = parse.getRemainingArgs(); if (remainingArgs.length != 2) { System.err.println("Usage: LineCount <input> <output>"); System.exit(-1);/*w w w. j a v a2 s. com*/ } Job job = Job.getInstance(conf, "LineCount"); job.setJarByClass(LineCount.class); job.setMapperClass(Map.class); job.setCombinerClass(Reduce.class); job.setReducerClass(Reduce.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); FileInputFormat.addInputPath(job, new Path(remainingArgs[0])); FileOutputFormat.setOutputPath(job, new Path(remainingArgs[1])); boolean success = job.waitForCompletion(true); //Get the counter here and print it Counters counters = job.getCounters(); long total = counters.findCounter(LcCounters.NUM_LINES).getValue(); System.out.println(Long.toString(total)); int res = success ? 0 : 1; System.exit(res); }
From source file:com.alectenharmsel.research.hadoop.MoabLicenseInfo.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parser = new GenericOptionsParser(new Configuration(), args); Configuration conf = parser.getConfiguration(); conf.set("mapreduce.output.textoutputformat.separator", ","); String[] remainingArgs = parser.getRemainingArgs(); if (remainingArgs.length != 2) { System.err.println("Usage: LineCount <input> <output>"); System.exit(-1);// ww w . j av a 2 s .co m } Job job = Job.getInstance(conf, "MoabLicenseInfo"); job.setJarByClass(MoabLicenseInfo.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); FileInputFormat.addInputPath(job, new Path(remainingArgs[0])); FileOutputFormat.setOutputPath(job, new Path(remainingArgs[1])); int res = job.waitForCompletion(true) ? 0 : 1; System.exit(res); }
From source file:com.alectenharmsel.research.LcCounters.java
License:Apache License
public static void main(String[] args) throws Exception { GenericOptionsParser parse = new GenericOptionsParser(new Configuration(), args); Configuration conf = parse.getConfiguration(); int res = ToolRunner.run(conf, new LineCount(), parse.getRemainingArgs()); System.exit(res);/*from w ww .j a v a2 s.co m*/ }