Commit 7e646317 authored by feng's avatar feng

Stripes 11

parent 18081da2
This diff is collapsed.
......@@ -4,6 +4,7 @@ import java.io.DataOutput;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.IntWritable;
......@@ -44,6 +45,14 @@ public class StringToIntMapWritable implements Writable {
public void write(DataOutput out) throws IOException {
// TODO: implement serialization
out.writeInt(this.hashMap.size());
for(Map.Entry<String, Integer> entry : this.hashMap.entrySet()){
this.word.set(entry.getKey());
this.count.set(entry.getValue());
this.word.write(out);
this.count.write(out);
}
/*
out.writeInt(hashMap.size());
Iterator iterator = hashMap.keySet().iterator();
while (iterator.hasNext()) {
......@@ -52,6 +61,7 @@ public class StringToIntMapWritable implements Writable {
word.write(out);
count.write(out);
}
*/
}
public void clear() {
......@@ -60,9 +70,9 @@ public class StringToIntMapWritable implements Writable {
public void add(String word) {
if (hashMap.containsKey(word)) {
hashMap.put(word, hashMap.get(word) + 1);
hashMap.put(word, (Integer)hashMap.get(word) + 1);
} else {
hashMap.put(word, 1);
hashMap.put(word, (Integer)1);
}
}
......
......@@ -76,7 +76,7 @@ class StripesMapper
Text, // TODO: change Object to output key type
StringToIntMapWritable> { // TODO: change Object to output value type
StringToIntMapWritable stripe = new StringToIntMapWritable();
private StringToIntMapWritable stripe = new StringToIntMapWritable();
@Override
public void map(LongWritable key, // TODO: change Object to input key type
Text value, // TODO: change Object to input value type
......
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