package nz.org.hikari.cat.ncdc_count;

// Mapper for NCDC record count MapReduce job, called from NcdcRecordCount
// driver class

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class NcdcRecordCountMapper
		extends Mapper<LongWritable, Text, Text, LongWritable> {
	
	static final LongWritable one = new LongWritable(1);

	@Override
	public void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		String line = value.toString();
		String id = line.substring(4, 10) + "-" + line.substring(10, 15);
		context.write(new Text(id), one);
	}

}

package nz.org.hikari.cat.ncdc_count;

// Mapper for NCDC record count MapReduce job, called from NcdcRecordCount
// driver class

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class NcdcRecordCountMapper
		extends Mapper<LongWritable, Text, Text, LongWritable> {
	
	@Override
	public void map(LongWritable key, Text value, Context context)
			throws IOException, InterruptedException {
		String line = value.toString();
		String id = line.substring(4, 10) + "-" + line.substring(10, 15);
		context.write(new Text(id), new LongWritable(1L));
	}

}

--- 
+++ 
@@ -12,12 +12,14 @@
 public class NcdcRecordCountMapper
 		extends Mapper<LongWritable, Text, Text, LongWritable> {
 	
+	static final LongWritable one = new LongWritable(1);
+
 	@Override
 	public void map(LongWritable key, Text value, Context context)
 			throws IOException, InterruptedException {
 		String line = value.toString();
 		String id = line.substring(4, 10) + "-" + line.substring(10, 15);
-		context.write(new Text(id), new LongWritable(1L));
+		context.write(new Text(id), one);
 	}
 
 }
ncdc_count: Create static LongWritable(1) outside mapper
