0

Yavcular 在 Hadoop 中使用 DistributedCache

在上面的链接中,以一种易于理解的方式描述了如何在 Hadoop 中使用 DistributedCache。但问题是,当我编译代码时,出现以下错误:

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

解决方法是什么?我无法将 Mapper 类更改为非静态,当我将loadIdUrlMapping方法签名更改为静态时,我无法访问idmapHashSet

4

1 回答 1

0

您需要发布您的代码版本以确定,但我想您有一个名为 cacheItemset 的方法,它被定义为静态范围:

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

loadUrlMapping 未定义为静态方法,因此您会收到编译错误。

如果您的ReplacementMapper类版本在它自己的类文件中,那么您不需要在类声明中使用 static 关键字(仅当 ReplacementMapper 类是另一个类的内部类时才需要)。

于 2012-07-20T10:37:30.633 回答