-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmazonFoodAnalytic.java
51 lines (35 loc) · 1.6 KB
/
AmazonFoodAnalytic.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package mapreduce.job1;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.apache.log4j.Logger;
public class AmazonFoodAnalytic extends Configured implements Tool {
private static final Logger LOG = Logger.getLogger(AmazonFoodAnalytic.class);
private AmazonFoodAnalytic() {}
public static void main(String[] args) throws Exception {
ToolRunner.run(new AmazonFoodAnalytic(), args);
}
@Override
@SuppressWarnings({ "static-access" })
public int run(String[] args) throws Exception {
long startTime = System.currentTimeMillis();
Job job = new Job(new Configuration(), "mapreduce.job1.AmazonFoodAnalytic");
job.setJarByClass(AmazonFoodAnalytic.class);
job.setMapperClass(AmazonFoodAnalyticMapper.class);
job.setReducerClass(AmazonFoodAnalyticReducer.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);
job.waitForCompletion(false);
LOG.info("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
return 0;
}
}