Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import org.apache.hadoop.io.*;
- import org.apache.hadoop.mapreduce.Mapper;
- public class DistCacheTestMapper extends Mapper<LongWritable, Text, Text, Text>
- {
- private Text word = new Text();
- private String line;
- @Override
- public void setup(Context con)
- {
- try {
- File file= new File("TestFile.txt");
- BufferedReader bf = new BufferedReader(new FileReader(file));
- while ((line=bf.readLine())!=null){
- word = new Text(line);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
- {
- context.write(new Text("test"), word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement