Skip to content

Commit 4f3fa79

Browse files
committed
Fix json output and hdfs reference fix
1 parent bdc95dd commit 4f3fa79

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = '0.2'
1+
version = '0.3'
22

33
// Modify these values if you want to build against different versions of Hadoop
44
hadoop_version = '0.20.2'

src/main/java/org/hackreduce/mappers/Stage2Mapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ public class Stage2Mapper extends Mapper<LongWritable, Text, Text, CityYearRecor
3939
@Override
4040
public void setup(Context context) {
4141
try {
42-
URI citiesURI = new URI("/datasets/geonames/");
43-
FileSystem fileSystem= FileSystem.get(citiesURI, context.getConfiguration());
42+
URI citiesURI = new URI("/");
43+
44+
FileSystem fileSystem= FileSystem.get(context.getConfiguration());
4445

4546
Reader reader;
46-
Path citiesPath = new Path("cities15000.txt");
47+
Path citiesPath = new Path("/datasets/geonames/cities15000.txt");
4748
if( fileSystem.exists(citiesPath) ) {
4849
FSDataInputStream in = fileSystem.open(citiesPath);
4950
reader = new InputStreamReader(in);

src/main/java/org/hackreduce/models/CityYearRecord.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ public void readFields(DataInput in) throws IOException {
6363

6464
public String toString(){
6565
String result = "{" ;
66-
result += "count:\"" + this.count + "\",";
67-
result += "city:\"" + this.cr.asciiname + "\",";
68-
result += "long:\"" + this.cr.longitude + "\",";
69-
result += "lat:\"" + this.cr.latitude + "\",";
70-
result += "year:\"" + this.year + "\",";
71-
result += "population:\"" + this.cr.population + "\",";
72-
result += "id:\"" + this.cr.geonameid + "\"}";
66+
result += "\"count\":\"" + this.count + "\",";
67+
result += "\"city\":\"" + this.cr.asciiname + "\",";
68+
result += "\"long\":\"" + this.cr.longitude + "\",";
69+
result += "\"lat\":\"" + this.cr.latitude + "\",";
70+
result += "\"year\":\"" + this.year + "\",";
71+
result += "\"population\":\"" + this.cr.population + "\",";
72+
result += "\"id\":\"" + this.cr.geonameid + "\"}";
7373
return result;
7474

7575
}

0 commit comments

Comments
 (0)