Hadoop自定义InputForma类,无法将其作为setnputormat的参数,请各位帮忙看看什么问题???

scdengyong 2014-03-05 12:42:32
想写一个自定义的InputFormat类
ImageFileInputormat类从继承Filenputormat<Text, Text>,这个类很简单,只需要得到输入路径下的文件名同时作为键和值。但是在conf.setInputFormat(ImageFileInputFormat.class),编译的时候出现一下错误:

ImageDemo.java:121: error: method setInputFormat in class JobConf cannot be applied to given types;
conf.setInputFormat(ImageFileInputFormat.class);
^
required: Class<? extends InputFormat>
found: Class<ImageFileInputFormat>
reason: actual argument Class<ImageFileInputFormat> cannot be converted to Class<? extends InputFormat> by method invocation conversion
1 error

请各位帮帮忙?看看我出现了什么问题,不胜感激!
...全文
222 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunyaning 2014-03-06
  • 打赏
  • 举报
回复
支持!!!!
villain001 2014-03-06
  • 打赏
  • 举报
回复
public void setInputFormat(Class<? extends InputFormat> theClass) public abstract class FileInputFormat<K, V> implements InputFormat<K, V> 如果真的继承FileInputFormat,是没有问题了,但是FileInputFormat在两个包下面存在, org.apache.hadoop.mapred org.apache.hadoop.mapreduce 我们使用的是org.apache.hadoop.mapred这个包下的,你检查一下,是不是继承错了。
scdengyong 2014-03-05
  • 打赏
  • 举报
回复
自己顶一下,求帮忙,现在卡在这里不知道怎么写了 想写一个自定义的InputFormat类 ImageFileInputormat类从继承Filenputormat<Text, Text>,这个类很简单,只需要得到输入路径下的文件名同时作为键和值。但是在conf.setInputFormat(ImageFileInputFormat.class),编译的时候出现一下错误: ImageDemo.java:121: error: method setInputFormat in class JobConf cannot be applied to given types; conf.setInputFormat(ImageFileInputFormat.class); ^ required: Class<? extends InputFormat> found: Class<ImageFileInputFormat> reason: actual argument Class<ImageFileInputFormat> cannot be converted to Class<? extends InputFormat> by method invocation conversion 1 error 请各位帮帮忙?看看我出现了什么问题,不胜感激!

778

社区成员

发帖
与我相关
我的任务
社区描述
云计算 网络相关讨论
社区管理员
  • 网络
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧