Commit ceef2947 authored by dangq's avatar dangq

Merge branch 'master' of gitlab.eurecom.fr:dangq/wordcount_lab

Conflicts:
	.idea/workspace.xml
	src/main/java/fr/eurecom/dsg/mapreduce/StringToIntMapWritable.java
	src/main/java/fr/eurecom/dsg/mapreduce/Stripes.java
parents a3871e7c 8f493184
This diff is collapsed.
......@@ -100,12 +100,12 @@ public class Pair extends Configured implements Tool {
// TODO: set map class and the map output key and value classes
job.setMapperClass(PairMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputKeyClass(TextPair.class);
job.setMapOutputValueClass(IntWritable.class);
// TODO: set reduce class and the reduce output key and value classes
job.setReducerClass(PairReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputKeyClass(TextPair.class);
job.setOutputValueClass(IntWritable.class);
// TODO: set job output format
......@@ -121,7 +121,7 @@ public class Pair extends Configured implements Tool {
// TODO: set the jar class
job.setJarByClass(WordCount.class);
job.setJarByClass(Pair.class);
job.waitForCompletion(true);
......
......@@ -5,8 +5,16 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
<<<<<<< HEAD
import java.util.Iterator;
import java.util.List;
=======
import java.util.TreeSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
>>>>>>> 8f49318439a759e7c34a55774d8d33aa3a91a874
import java.util.Map.Entry;
import java.util.Set;
import java.util.ArrayList;
......@@ -22,6 +30,7 @@ public class StringToIntMapWritable implements Writable {
// TODO: add an internal field that is the real associative array
private HashMap<String, Integer> hm = new HashMap<String,Integer>();
<<<<<<< HEAD
@Override
public void readFields(DataInput in) throws IOException {
// TODO: implement deserialization
......@@ -50,6 +59,50 @@ public class StringToIntMapWritable implements Writable {
}
return result;
}
=======
>>>>>>> 8f49318439a759e7c34a55774d8d33aa3a91a874
public Set<String> getKeySet() {
return hm.keySet();
}
<<<<<<< HEAD
public Integer getValue(String key) {
return hm.get(key);
=======
// TODO: implement deserialization
int len =in.readInt();
hm.clear();
for (int i=0;i<len;i++){
int l=in.readInt();
byte[] ba =new byte[l];
in.readFully(ba);
String key=new String(ba);
Integer value=in.readInt();
hm.put(key,value);
}
>>>>>>> 8f49318439a759e7c34a55774d8d33aa3a91a874
}
public StringToIntMapWritable(){
<<<<<<< HEAD
=======
}
public StringToIntMapWritable(String key, Integer value){
hm.put(key,value);
}
public List<StringToIntMapWritable> getElements(){
List<StringToIntMapWritable> result = new ArrayList<StringToIntMapWritable>();
for (String key : hm.keySet()) {
result.add(new StringToIntMapWritable(key, hm.get(key)));
}
return result;
}
public Set<String> getKeySet() {
return hm.keySet();
......@@ -59,6 +112,7 @@ public class StringToIntMapWritable implements Writable {
return hm.get(key);
}
>>>>>>> 8f49318439a759e7c34a55774d8d33aa3a91a874
@Override
public String toString() {
return hm.keySet().iterator().next() + " " + hm.values().iterator().next();
......
......@@ -131,4 +131,8 @@ class StripesReducer extends Reducer<Text, // input key type
}
}
}
\ No newline at end of file
<<<<<<< HEAD
}
=======
}
>>>>>>> 8f49318439a759e7c34a55774d8d33aa3a91a874
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment