我是MapReduce的新手。我看到许多在MapReduce中编写的代码并声明了静态变量。在mapreduce中使用static关键字在Mapper类中
例子:
public class Map extends Mapper<Object, Text, Text, IntWritable>{
private static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context){
//Mapper code
}
}
}
但是有一个疑问,我知道每一个地图的任务是在不同的JVM实例化。那么Mapper实例如何共享静态变量?如果他们不能共享,那么静态变量的用法是什么?
[this]的可能重复(http://stackoverflow.com/questions/24280415/hadoop-map-reduce-task-and-static-variable)。 – YoungHobbit