Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test.invertedIndex
- import java.io.IOException;
- import java.util.Iterator;
- import org.apache.hadoop.io.Text;
- import org.apache.hadoop.mapred.OutputCollector;
- import org.apache.hadoop.mapred.MapReduceBase;
- import org.apache.hadoop.mapred.Reducer;
- import org.apache.hadoop.mapred.Reporter;
- import scala.collection.JavaConversions._
- class invertedReducer() extends MapReduceBase
- with Reducer[Text, Text, Text, Text] {
- val finalValue = new Text();
- def reduce(key : Text,
- values: Iterator[Text],
- output: OutputCollector[Text, Text] ,
- reporter: Reporter) {
- // Take all the values and concatinate them together with a , in between them
- finalValue.set(values.foldLeft("")(_ +"," +_) )
- output.collect(key, finalValue);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement