Advertisement
Guest User

Untitled

a guest
Dec 17th, 2011
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.File;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import org.apache.hadoop.io.*;
  7. import org.apache.hadoop.mapreduce.Mapper;
  8.  
  9. public class DistCacheTestMapper extends Mapper<LongWritable, Text, Text, Text>
  10. {
  11. private Text word = new Text();
  12. private String line;
  13.  
  14. @Override
  15. public void setup(Context con)
  16. {
  17. try {
  18. File file= new File("TestFile.txt");
  19. BufferedReader bf = new BufferedReader(new FileReader(file));
  20. while ((line=bf.readLine())!=null){
  21. word = new Text(line);
  22. }
  23. } catch (FileNotFoundException e) {
  24. e.printStackTrace();
  25. } catch (IOException e) {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29. }
  30.  
  31.  
  32. public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
  33. {
  34. context.write(new Text("test"), word);
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement