hadoop mapper static initialisation
Posted
by rakeshr
on Stack Overflow
See other posts from Stack Overflow
or by rakeshr
Published on 2010-06-03T23:06:26Z
Indexed on
2010/06/05
19:32 UTC
Read the original article
Hit count: 230
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.
© Stack Overflow or respective owner