//SalesCountry.
java
package SalesCountry;
import [Link];
import [Link].*;
import [Link].*;
public class SalesCountryDriver
{
public static void main(String[] args)
{
JobClient my_client = new JobClient();
// Create a configuration object for the job
JobConf job_conf = new JobConf([Link]);
// Set a name of the Job
job_conf.setJobName("SalePerCountry");
// Specify data type of output key and value
job_conf.setOutputKeyClass([Link]);
job_conf.setOutputValueClass([Link]);
// Specify names of Mapper and Reducer Class
job_conf.setMapperClass([Link]);
job_conf.setReducerClass([Link]);
// Specify formats of the data type of Input and output
job_conf.setInputFormat([Link]);
job_conf.setOutputFormat([Link]);
// Set input and output directories using command line arguments,
//arg[0] = name of input directory on HDFS, and arg[1] = name of output
//directory to be created to store the output file.
[Link](job_conf, new Path(args[0]));
[Link](job_conf, new Path(args[1]));
my_client.setConf(job_conf);
try {
// Run the job
[Link](job_conf);
}
catch (Exception e) { [Link](); }
}
}
//[Link]
package SalesCountry;
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link].*;
public class SalesCountryReducer extends MapReduceBase implements
Reducer<Text, IntWritable, Text, IntWritable>
{
public void reduce(Text t_key, Iterator<IntWritable> values, r<Text,IntWritable>
output, Reporter reporter) throws IOException
{
Text key = t_key;
int frequencyForCountry = 0;
while ([Link]())
{
// replace type of value with the actual type of our value
IntWritable value = (IntWritable) [Link]();
frequencyForCountry += [Link]();
}
[Link](key, new IntWritable(frequencyForCountry));
}
}
//[Link]
package SalesCountry;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
public class SalesMapper extends MapReduceBase implements
Mapper<LongWritable, Text, Text, IntWritable>
{
private final static IntWritable one = new IntWritable(1);
public void map(LongWritable key, Text value, OutputCollector<Text,
IntWritable> output, Reporter reporter) throws IOException
{
String valueString = [Link]();
String[] SingleCountryData = [Link](",");
[Link](new Text(SingleCountryData[7]),one);
}
}