0

Using DistributedCache in Hadoop by Yavcular

In the above link, it is described how to use DistributedCache in Hadoop in an easy to understand way. But the problem is, when I trt to compile the code, I get the following error:

non-static method loadIdUrlMapping(org.apache.hadoop.mapreduce.Mapper.Context) cannot be referenced from a static context
        loadIdUrlMapping(context);

What is the workaround? I can not change the Mapper class to non-static, and when I change loadIdUrlMapping method signature to static, then I can not access the idmap HashSet

Ahmadov
  • 1,567
  • 5
  • 31
  • 48

1 Answers1

0

You'll need to post your version of the code to be sure, but i imagine you have a method called cacheItemset which is defined as static scope:

public static void cacheItemset(Context) {
    loadIdUrlMapping(context);
}

loadUrlMapping is not defined as a static method, and therefore you are getting a compile error.

If you version of the ReplacementMapper class is in it's own class file, then you do not need the static keyword in the class declaration (this is only required if the ReplacementMapper class was an inner-class of another class).

Chris White
  • 29,949
  • 4
  • 71
  • 93
  • sorry, I just changed loadIdUrlMapping(Context context) to cacheItemset(Context context). the same thing. – Ahmadov Jul 21 '12 at 02:48
  • I have solved the problem myself. The thing was that instead of placing the method inside the static map class, I wrongly places inside the main public class. Moved the method, problem solved. thanks for your help – Ahmadov Jul 25 '12 at 15:40