Skip to content

Commit 196df74

Browse files
committed
Added CityYearRecord
1 parent 4d8693b commit 196df74

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.hackreduce.examples;
2+
3+
import org.apache.hadoop.conf.Configuration;
4+
import org.apache.hadoop.conf.Configured;
5+
import org.apache.hadoop.fs.FileSystem;
6+
import org.apache.hadoop.fs.Path;
7+
import org.apache.hadoop.io.NullWritable;
8+
import org.apache.hadoop.io.Text;
9+
import org.apache.hadoop.mapreduce.Job;
10+
import org.apache.hadoop.mapreduce.Reducer;
11+
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
12+
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
13+
import org.apache.hadoop.util.Tool;
14+
import org.apache.hadoop.util.ToolRunner;
15+
import org.hackreduce.mappers.BixiMapper;
16+
import org.hackreduce.models.BixiRecord;
17+
18+
/**
19+
*
20+
*/
21+
public class Stage2Reducer extends Reducer<Text, CityYearRecord, Text,CityYearRecord> {
22+
ationReduce
23+
24+
25+
public void reduce(Key key, Iterable<CityYearRecord> values,
26+
Context context) throws IOException {
27+
int sum = 0;
28+
for (CityYearRecord val : values) {
29+
sum += val.getCount();
30+
}
31+
String year = key.
32+
CityYearRecord result = new CityYearRecord(,,sum) ;
33+
context.collect(year, result);
34+
}
35+
}
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.hackreduce.models;
2+
3+
public class CityYearRecord {
4+
private String cityName;
5+
private String year;
6+
private int count;
7+
8+
public CityYearRecord(String cityName, String year, int count){
9+
this.cityName = cityName;
10+
this.year = year;
11+
this.count = count;
12+
}
13+
14+
public String getCityName(){
15+
return cityName;
16+
}
17+
18+
public String getYear(){
19+
return year;
20+
21+
}
22+
23+
public int getCount(){
24+
return count;
25+
}
26+
27+
public void setCityRecord(String cityName){
28+
this.cityName = cityName;
29+
}
30+
31+
public void setCount(int count){
32+
this.count = count;
33+
}
34+
35+
public void setYear(String year){
36+
this.year = year;
37+
}
38+
39+
40+
}

0 commit comments

Comments
 (0)