Hi,
I have a code fragment in which I am using a static code block to initialize a variable.
public static class JoinMap extends
Mapper<IntWritable, MbrWritable, LongWritable, IntWritable> {
.......
public static RTree rt = null;
static {
String rtreeFileName = "R.rtree";
rt = new RTree(rtreeFileName);
}
public void map(IntWritable key, MbrWritable mbr,Context context)
throws IOException, InterruptedException {
.........
List elements = rt.overlaps(mbr.getRect());
.......
}
}
My problem is that the variable rt in the above code fragment is not getting initialised. Can anybody suggest a fix or an alternate way to initialise the variable. I don't want to initialise it inside my map function since that slows down the entire process.