-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonidasales.java
More file actions
68 lines (50 loc) · 1.83 KB
/
onidasales.java
File metadata and controls
68 lines (50 loc) · 1.83 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
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.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
public class OnidaSales
{
@SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException
{
//Check if input parameters provided appropriately
if(args==null || args.length!=2)
{
System.err.println("Incorrect jar or output directory provided");
System.exit(-1);
}
//Instantiate configuration object
Configuration conf = new Configuration();
//Instantiate job object
Job job = new Job(conf,"OnidaSales");
job.setJarByClass(OnidaSales.class);
/*
* Set input pathput
*/
FileInputFormat.setInputPaths(job, new Path(args[0]));
/*
* Set output path
*/
Path outputPath = new Path(args[1]);
FileOutputFormat.setOutputPath(job, outputPath);
//Delete output directory if already existing will fail if present
outputPath.getFileSystem(conf).delete(outputPath, true);
//Set mapper class
job.setMapperClass(OnidaSalesMapper.class);
job.setReducerClass(OnidaSalesReducer.class);
//Set input and output format class
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
//Set output key'value class types
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
//Execute the job and wait until completion and then exit
System.exit(job.waitForCompletion(true)?0:1);
}
}