Hadoop 流示例失败映射中的键类型不匹配
中的键类型不匹配而
当我运行 Hadoop 流示例时,它因 Map Hadoop 版本 0.21.0 输入文件内容:
adfad
adfasdflkjlj
命令行:$HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar \ -输入myInputDirs \ -输出 myOutputDir \ -mapper org.apache.hadoop.mapred.lib.IdentityMapper \ -reducer /bin/wc
我得到的错误:
java.lang.Exception:java.io.IOException:映射中的键类型不匹配:预期的 org.apache.hadoop.io.Text,已收到 org.apache.hadoop.io.LongWritable
请指教。我做错了什么?谢谢
Possible Duplicate:
hadoop-streaming example failed to run - Type mismatch in key from map
When I ran Hadoop streaming example, it failed with Type mismatch in key from map
Hadoop version 0.21.0
input file content:
adfad
adfasdflkjlj
Command line: $HADOOP_HOME/bin/hadoop jar $HADOOP_HOME/hadoop-streaming.jar \
-input myInputDirs \
-output myOutputDir \
-mapper org.apache.hadoop.mapred.lib.IdentityMapper \
-reducer /bin/wc
Error I got:
java.lang.Exception: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.Text, recieved org.apache.hadoop.io.LongWritable
Please advise. What did I do wrong? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:抱歉,没有意识到这是流媒体。您需要自定义如何将输出拆分为键/值对。文档位于: http://hadoop.apache.org/common/docs/current/streaming.html#Customizing+How+Lines+are+Split+into+Key%2FValue+Pairs
The error message gives you all that you need to know. Your mapper is defined as outputting LongWritable keys: `Mapper`, and your Reducer expects Text: `Reducer.`
You need to redefine one or the other of them.
EDIT: Sorry, didn't realize this is Streaming. You need to customize how your output is split into Key/Value pairs. The documentation is here: http://hadoop.apache.org/common/docs/current/streaming.html#Customizing+How+Lines+are+Split+into+Key%2FValue+Pairs
The error message gives you all that you need to know. Your mapper is defined as outputting LongWritable keys: `Mapper`, and your Reducer expects Text: `Reducer.`
You need to redefine one or the other of them.
这是 Hadoop 发行版本中的一个已知错误。它已在代码中修复,但必须发布。 此处提供了替代解决方案 。
It's a known bug in the release versions of Hadoop. It has been fixed in the code, but has to be released. Alternate solution provided here.