List of usage examples for org.apache.hadoop.mapred JobConf setMapperClass
public void setMapperClass(Class<? extends Mapper> theClass)
From source file:FormatStorage2ColumnStorageMR.java
License:Open Source License
@SuppressWarnings("deprecation") public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("FormatStorage2ColumnStorageMR <input> <output>"); System.exit(-1);//from www. j a v a 2s. c o m } JobConf conf = new JobConf(FormatStorageMR.class); conf.setJobName("FormatStorage2ColumnStorageMR"); conf.setNumMapTasks(1); conf.setNumReduceTasks(4); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Unit.Record.class); conf.setMapperClass(FormatStorageMapper.class); conf.setReducerClass(ColumnStorageReducer.class); conf.setInputFormat(FormatStorageInputFormat.class); conf.set("mapred.output.compress", "flase"); Head head = new Head(); initHead(head); head.toJobConf(conf); FileInputFormat.setInputPaths(conf, args[0]); Path outputPath = new Path(args[1]); FileOutputFormat.setOutputPath(conf, outputPath); FileSystem fs = outputPath.getFileSystem(conf); fs.delete(outputPath, true); JobClient jc = new JobClient(conf); RunningJob rj = null; rj = jc.submitJob(conf); String lastReport = ""; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS"); long reportTime = System.currentTimeMillis(); long maxReportInterval = 3 * 1000; while (!rj.isComplete()) { try { Thread.sleep(1000); } catch (InterruptedException e) { } int mapProgress = Math.round(rj.mapProgress() * 100); int reduceProgress = Math.round(rj.reduceProgress() * 100); String report = " map = " + mapProgress + "%, reduce = " + reduceProgress + "%"; if (!report.equals(lastReport) || System.currentTimeMillis() >= reportTime + maxReportInterval) { String output = dateFormat.format(Calendar.getInstance().getTime()) + report; System.out.println(output); lastReport = report; reportTime = System.currentTimeMillis(); } } System.exit(0); }
From source file:BP.java
License:Apache License
protected JobConf configInitMessage() throws Exception { final JobConf conf = new JobConf(getConf(), BP.class); conf.set("nstate", "" + nstate); conf.set("compat_matrix_str", "" + edge_potential_str); conf.setJobName("BP_Init_Belief"); conf.setMapperClass(MapInitializeBelief.class); fs.delete(message_cur_path, true);/*w w w. j ava 2 s . com*/ FileInputFormat.setInputPaths(conf, edge_path); FileOutputFormat.setOutputPath(conf, message_cur_path); conf.setNumReduceTasks(0); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); return conf; }
From source file:BP.java
License:Apache License
protected JobConf configUpdateMessage() throws Exception { final JobConf conf = new JobConf(getConf(), BP.class); conf.set("nstate", "" + nstate); conf.set("compat_matrix_str", "" + edge_potential_str); conf.setJobName("BP_Update_message"); conf.setMapperClass(MapUpdateMessage.class); conf.setReducerClass(RedUpdateMessage.class); fs.delete(message_next_path, true);//from ww w .jav a2 s. com FileInputFormat.setInputPaths(conf, message_cur_path, prior_path); FileOutputFormat.setOutputPath(conf, message_next_path); conf.setNumReduceTasks(nreducer); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Text.class); return conf; }
From source file:BP.java
License:Apache License
protected JobConf configCheckErr() throws Exception { final JobConf conf = new JobConf(getConf(), BP.class); conf.set("nstate", "" + nstate); conf.setJobName("BP_Check Err"); fs.delete(check_error_path, true);/*from ww w . j a va2s.co m*/ conf.setMapperClass(MapCheckErr.class); conf.setReducerClass(RedCheckErr.class); FileInputFormat.setInputPaths(conf, message_cur_path, message_next_path); FileOutputFormat.setOutputPath(conf, check_error_path); conf.setNumReduceTasks(nreducer); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Text.class); return conf; }
From source file:BP.java
License:Apache License
protected JobConf configSumErr() throws Exception { final JobConf conf = new JobConf(getConf(), BP.class); conf.set("nstate", "" + nstate); conf.setJobName("BP_Sum Err"); fs.delete(sum_error_path, true);//from w ww .j a v a 2s. c om conf.setMapperClass(MapSumErr.class); conf.setReducerClass(RedSumErr.class); FileInputFormat.setInputPaths(conf, check_error_path); FileOutputFormat.setOutputPath(conf, sum_error_path); conf.setNumReduceTasks(1); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Text.class); return conf; }
From source file:BP.java
License:Apache License
protected JobConf configComputeBelief() throws Exception { final JobConf conf = new JobConf(getConf(), BP.class); conf.set("nstate", "" + nstate); conf.set("compat_matrix_str", "" + edge_potential_str); conf.setJobName("BP_Compute_Belief"); conf.setMapperClass(MapComputeBelief.class); conf.setReducerClass(RedComputeBelief.class); fs.delete(output_path, true);/*from w w w . j a v a 2s .co m*/ FileInputFormat.setInputPaths(conf, message_cur_path, prior_path); FileOutputFormat.setOutputPath(conf, output_path); conf.setNumReduceTasks(nreducer); conf.setOutputKeyClass(LongWritable.class); conf.setOutputValueClass(Text.class); return conf; }
From source file:FriendsJob.java
License:Apache License
/** * @param args/* w ww . j a v a2 s . c om*/ */ public static void main(String[] args) throws Exception { JobConf conf = new JobConf(FriendsJob.class); conf.setJobName("anagramcount"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(FriendsMapper.class); // conf.setCombinerClass(AnagramReducer.class); conf.setReducerClass(FriendsReducer.class); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(TextOutputFormat.class); FileInputFormat.setInputPaths(conf, new Path(args[0])); FileOutputFormat.setOutputPath(conf, new Path(args[1])); JobClient.runJob(conf); }
From source file:SleepJobWithArray.java
License:Apache License
public JobConf setupJobConf(int numMapper, int numReducer, long mapSleepTime, int mapSleepCount, long reduceSleepTime, int reduceSleepCount) { JobConf job = new JobConf(getConf(), SleepJobWithArray.class); job.setNumMapTasks(numMapper);// w w w .ja v a 2s . co m job.setNumReduceTasks(numReducer); job.setMapperClass(SleepJobWithArray.class); job.setMapOutputKeyClass(IntWritable.class); job.setMapOutputValueClass(NullWritable.class); job.setReducerClass(SleepJobWithArray.class); job.setOutputFormat(NullOutputFormat.class); job.setInputFormat(SleepInputFormat.class); job.setPartitionerClass(SleepJobWithArray.class); job.setSpeculativeExecution(false); FileInputFormat.addInputPath(job, new Path("ignored")); job.setLong("sleep.job.map.sleep.time", mapSleepTime); job.setLong("sleep.job.reduce.sleep.time", reduceSleepTime); job.setInt("sleep.job.map.sleep.count", mapSleepCount); job.setInt("sleep.job.reduce.sleep.count", reduceSleepCount); return job; }
From source file:AnagramJob.java
License:Apache License
/** * @param args/*from w w w.j a v a 2s . c o m*/ */ public static void main(String[] args) throws Exception { JobConf conf = new JobConf(AnagramJob.class); conf.setJobName("anagramcount"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(AnagramMapper.class); // conf.setCombinerClass(AnagramReducer.class); conf.setReducerClass(AnagramReducer.class); conf.setInputFormat(TextInputFormat.class); conf.setOutputFormat(TextOutputFormat.class); FileInputFormat.setInputPaths(conf, new Path(args[0])); FileOutputFormat.setOutputPath(conf, new Path(args[1])); JobClient.runJob(conf); }
From source file:CountHistogram.java
License:Open Source License
@Override public int run(String[] args) throws Exception { try {/* ww w .j a v a2 s.co m*/ JobClient client = new JobClient(); JobConf job = new JobConf(getConf(), CountHistogram.class); job.setJobName("CountHistogram"); job.setOutputKeyClass(IntWritable.class); job.setOutputValueClass(IntWritable.class); job.setMapperClass(Map.class); job.setReducerClass(Reduce.class); job.setInputFormat(TextInputFormat.class); job.setOutputFormat(TextOutputFormat.class); FileInputFormat.setInputPaths(job, new Path(args[0])); FileOutputFormat.setOutputPath(job, new Path(args[1])); client.setConf(job); JobClient.runJob(job); } catch (Exception e) { e.printStackTrace(); throw e; } return 0; }