您的位置:首页 > 运维架构 > Apache

Hadoop-mapreduce org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text错误

2017-08-02 09:57 1111 查看
java.lang.Exception: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text

(Hadoop的输入LongWritable不能转变为Text)

When you read a file with a M/R program, the input key of your mapper should be the index of the line in the file, while the input value will be the full line.So here what's happening is that
you're trying to have the line index as a Text object which is wrong, and you need an LongWritable instead so that Hadoop doesn't
complain about type.

        当你用MapReduce程序读入文件是,mapper的输入key值应该是文件当前行的索引值,文件当前行的所有内容会被当做mapper的输入value值。所以Mapper程序的第一个参数(Mapper类的输入Key值)不可以具体化为LongWritable,可以用Text或者Object类。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hadoop
相关文章推荐