public int getPartition (IntWritable key, IntWritable value, int numPartitions)
Here the numPartitions related to drink? How to set? Not in the Job related Settings (NumReduceTask), how much is this parameter numPartitions default values,
All the concrete example code stick in the following:
import org, apache hadoop. Conf. Configuration;
Import org, apache hadoop. Fs. The Path;
Import org, apache hadoop. IO. IntWritable;
Import org, apache hadoop. IO. Text;
Import org, apache hadoop. Graphs. The Job;
Import org, apache hadoop. Graphs. Mapper;
Import org, apache hadoop. The graphs. The Partitioner.
Import org, apache hadoop. Graphs. Reducer;
Import org, apache hadoop. Graphs. Lib. Input. FileInputFormat;
Import org, apache hadoop. Graphs. Lib. Output. FileOutputFormat;
Import org, apache hadoop. Util. GenericOptionsParser;
Import the Java. IO. IOException;
/* *
* Created by dell on 2017/9/25.
* @ auther w*
*/
Public class MySort {
The static final String INPUT_PATH="HDFS://hadoopwang0:9000/test".
The static final String OUT_PATH="HDFS://hadoopwang0:9000/testout";
Public static void main (String [] args) throws IOException, ClassNotFoundException, InterruptedException {
Configuration conf=new Configuration();
//String [] otherArgs=new GenericOptionsParser (conf, args). GetRemainingArgs ();
//if (otherArgs length!=2) {
//System. Err. Println (" the Usage: wordcount & lt; In>" );
//System. Exit (2);
//}
Job Job=new Job (conf, "MySort");
Job. SetJarByClass (MySort. Class);
Job. SetMapperClass (MyMap. Class);
Job. SetReducerClass (MyReduce. Class);
Job. SetPartitionerClass (MyPartition. Class);
Job. SetOutputKeyClass (IntWritable. Class);
Job. SetOutputValueClass (IntWritable. Class);
FileInputFormat. AddInputPath (job, new Path (INPUT_PATH));
FileOutputFormat. SetOutputPath (job, new Path (OUT_PATH));
System. The exit (job. WaitForCompletion (true)? 1-0);
}
//the Map method: the input value into IntWritable type, as the Key of the output,
Public static class MyMap extends Mapper
CodePudding user response:
Thanks for sharing, with a great help for beginnersCodePudding user response:
Thanks for sharing, with a great help for beginners