Hi,

Static inner classes, and the static fields are different things in java. Hadoop needs to instantiate the Mapper and Reducer classes from their class names, so if they are defined as inner classes, they need to be static. You can either declare the inner classes to be static, and use the class normally(accessing non-static data), or refactor Mapper and Reducer classes to their own files.

Deyaa Adranale wrote:
hello.
why do we have to set the map and reduce classes as static?
i need inside them to access some data which is not static. what i should do?

non static map or reduce classes generates the following exception:

java.lang.RuntimeException: java.lang.NoSuchMethodException: hadoop.examples.Simple$MyMapper.() at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:45)
   at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:32)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:53)
   at org.apache.hadoop.mapred.MapTask.run(MapTask.java:209)
at org.apache.hadoop.mapred.TaskTracker$Child.main(TaskTracker.java:1210) Caused by: java.lang.NoSuchMethodException: hadoop.examples.Simple$MyMapper.()
   at java.lang.Class.getConstructor0(Class.java:2705)
   at java.lang.Class.getDeclaredConstructor(Class.java:1984)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:41)
   ... 4 more




any ideas?

thanks in advance,

Deyaa

Reply via email to