Demo entry 6344397

java

   

Submitted by anonymous on Jan 13, 2017 at 01:00
Language: Java. Code size: 420 Bytes.

public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

	@Override
	public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String s = value.toString();
for (String w : s.split(" ")) {
			if (w.length() > 0) {
				if (w.charAt(0) == 'N' || w.charAt(0) == 'P')
					context.write(new Text(w), new IntWritable(1));
			}
		}
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).