Created
August 27, 2012 14:49
-
-
Save geofferyzh/3489170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.io.Text; | |
import org.apache.hadoop.mapred.FileInputFormat; | |
import org.apache.hadoop.mapred.FileOutputFormat; | |
import org.apache.hadoop.mapred.JobClient; | |
import org.apache.hadoop.mapred.JobConf; | |
import org.apache.hadoop.conf.Configured; | |
import org.apache.hadoop.util.Tool; | |
import org.apache.hadoop.util.ToolRunner; | |
public class pymk extends Configured implements Tool { | |
@Override | |
public int run(String[] args) throws Exception { | |
if (args.length != 2) { | |
System.out.printf( | |
"Usage: %s [generic options] <input dir> <output dir>\n", getClass() | |
.getSimpleName()); | |
ToolRunner.printGenericCommandUsage(System.out); | |
return -1; | |
} | |
JobConf conf = new JobConf(getConf(), pymk.class); | |
conf.setJobName(this.getClass().getName()); | |
FileInputFormat.setInputPaths(conf, new Path(args[0])); | |
FileOutputFormat.setOutputPath(conf, new Path(args[1])); | |
conf.setMapperClass(pymk_mapper.class); | |
conf.setReducerClass(pymk_reducer.class); | |
conf.setMapOutputKeyClass(Text.class); | |
conf.setMapOutputValueClass(Text.class); | |
conf.setOutputKeyClass(Text.class); | |
conf.setOutputValueClass(Text.class); | |
JobClient.runJob(conf); | |
return 0; | |
} | |
public static void main(String[] args) throws Exception { | |
int exitCode = ToolRunner.run(new pymk(), args); | |
System.exit(exitCode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment