List of usage examples for org.apache.hadoop.io SortedMapWritable clear
@Override
public void clear()
From source file:Assignment4_P4_MemoryConscious.MovingRatingMemConscious_Combiner.java
public void reduce(IntWritable key, Iterable<SortedMapWritable> values, Context context) throws IOException, InterruptedException { // loop through each hashmap for this movie id for (SortedMapWritable val : values) { // inside each hashmap, loop for every entry for (Map.Entry<WritableComparable, Writable> entry : val.entrySet()) { // check if current entry's key is already present in new hashmap if (result.containsKey(entry.getKey())) { //if yes, extract current value from result hashmap for this key LongWritable existingValue = (LongWritable) result.get(entry.getKey()); // increment existing value by 1 existingValue.set(existingValue.get() + 1); // update result hashmap with new value result.put(entry.getKey(), existingValue); } else { //if not, create new entry with init value 1 result.put(entry.getKey(), new LongWritable(1)); }//from w w w.j a v a2 s . c o m } val.clear(); } context.write(key, result); }