- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试编写一个代码,我可以根据字符的长度自定义输入将转到 reducer,使用实现到默认 Mapper 和 Reducer 的分区,但出现以下错误。我会感谢帮助我的人。
int setNumRedTasks) 错误
:
Name clash: The method getPartition(Object, Object, int) of type MyPartitioner has the same erasure as getPartition(K2, V2, int) of type Partitioner but does not override it
代码:
package partition;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.Partitioner;
public abstract class MyPartitioner implements Partitioner<Text, IntWritable>{
@Override
public void configure(JobConf arg0) {
// TODO Auto-generated method stub
}
// @Override
public int getPartition(Object key, Object value, int setNumRedTasks) {
String s = key.toString();
if(s.length()==1)
{
return 0;
}
if(s.length()==2)
{
return 1;
}
if(s.length()==3)
{
return 2;
}
else
return 3;
}
}
最佳答案
您的getPartition
方法签名有误,需要:
public int getPartition(Text key, IntWritable value, int setNumRedTasks) {
... Code goes here
}
这个 SO 答案解释了删除错误的含义:Method has the same erasure as another method in type
实际上,因为您使用的是 Object 而不是泛型类型,所以无法确定要使用哪个版本,它们是等价的。
关于java - Partitioner 类型的 getPartition 的名称冲突在 MapReduce、Hadoop 中具有相同类型主类的删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45952814/
在C#交互窗口中运行以下代码 using System.Collections.Concurrent; var l = Enumerable.Range(0, 20); Partitioner.Cre
本文整理了Java中org.apache.lens.api.metastore.XPartitionList.getPartition()方法的一些代码示例,展示了XPartitionList.get
我正在尝试编写一个代码,我可以根据字符的长度自定义输入将转到 reducer,使用实现到默认 Mapper 和 Reducer 的分区,但出现以下错误。我会感谢帮助我的人。 int setNumRed
我是一名优秀的程序员,十分优秀!