博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MapReduce——LongWritable cannot be cast to org.apache.hadoop.io.Text 错误原因
阅读量:4094 次
发布时间:2019-05-25

本文共 754 字,大约阅读时间需要 2 分钟。

            运行环境:虚拟机,Ubuntu16,Ubuntu Server 做集群(一主两从),编程软件eclipse。

           运行时出现如下错误:

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.

        在stackoverflow上找到了答案:当你用MapReduce程序读入文件是,mapper的输入key值应该是文件当前行的索引值,文件当前行的所有内容会被当做mapper的输入value值。所以Mapper程序的第一个参数(Mapper类的输入Key值)不可以具体化为LongWritable,可以用Text或者Object类。

参考stackoverflow:

转载地址:http://sntii.baihongyu.com/

你可能感兴趣的文章
人工神经网络——感知器介绍
查看>>
人工神经网络——反向传播算法(BackPropagation)
查看>>
进程的地址空间概述
查看>>
Windows 窗口底层原理
查看>>
一种函数指针的运用
查看>>
Win32程序之进程的原理
查看>>
C++虚函数原理
查看>>
MySQL的索引
查看>>
今天,Python信息量很大!
查看>>
Flash 已死,Deno 当立?
查看>>
编程差的程序员,90%都是吃了数学的亏!骨灰级开发:方法不对,努力也白费...
查看>>
编程差的程序员,90%都是吃了数学的亏!骨灰级开发:方法不对,努力也白费...
查看>>
都无代码了,还要程序员吗?
查看>>
程序员:凭自己能力吃饭,有什么理由瞧不起?
查看>>
面试想拿 10K,HR 说我只配7k?
查看>>
副业过万的程序员都知道的网站有哪些
查看>>
那些人生“开挂”的程序员,都在干什么?
查看>>
影响科学圈的那些计算机代码
查看>>
乐视视频 App 图标改为“欠 122 亿”,网友:我在别家分红包,却在你家随份子!...
查看>>
乔布斯18岁求职信拍卖价22.24万美元,值吗?
查看>>