Hadoop Map Reduce reference static objects

前端 未结 3 1210
無奈伤痛
無奈伤痛 2021-01-07 03:38

I have a static object in my map reduce job class that I want to initialize once (in the main method), then call a function on it in every mapping. So I have this object, M

3条回答
  •  囚心锁ツ
    2021-01-07 03:58

    Your main() doesn't get invoked on every node, it only runs where you start up the job. In order to have access to your static object, it needs to be initialized at the instantiation of the mapper. That way the initialization will happen on every node that runs a map task.

    But there may be another way to do what you're trying to accomplish, so the question is, what does this static object do?

提交回复
热议问题