Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
- private static final Pattern pattern = Pattern.compile("\"([^\"]*)\"");
- private final static IntWritable one = new IntWritable(1);
- private Text word = new Text();
- public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
- Matcher matcher = pattern.matcher(value.toString());
- if (matcher.find()) {
- word.set(matcher.group(0));
- context.write(word, one);
- }
- }
- }
Add Comment
Please, Sign In to add comment