xml - Hadoop Job API支持StreamInputFormat吗?

标签 xml hadoop mapreduce

我正在尝试使用Hadoop的StreamInputFormat处理xml文件。我为此使用了较新的API(Hadoop-0.20.205.0)。但是,似乎Job不支持StreamInputFormat,因为当我尝试通过“job.setInputFormatClass(StreamInputFormat.class)”设置属性时,它显示-

"The method setInputFormatClass(Class<? extends InputFormat>) in the type Job is not pplicable for the arguments (Class<StreamInputFormat>)"

我什至已经明确下载了“hadoop-streaming-0.20.205.0.jar”并导入了“org.apache.hadoop.streaming”包,仍然没有运气。有什么建议吗?

最佳答案

您正在尝试将旧API InputFormat(mapred)与新的API客户端Job(mapreduce)结合使用。
Job.setInputFormat()期待一个扩展o.a.h.mapreduce.InputFormat(新的“mapreduce” API)的类,其中流式API都是用旧API(“mapred”包)编写的,而StreamInputFormat扩展了o.a.h.mapred.KeyValueTextInputFormat,后者又扩展了o.a.h.mapred.FileInputFormat(两者都是旧的API):

  • http://svn.apache.org/viewvc/hadoop/common/tags/release-0.20.205.0/src/contrib/streaming/src/java/org/apache/hadoop/streaming/StreamInputFormat.java?view=markup
  • 关于xml - Hadoop Job API支持StreamInputFormat吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11101456/

    相关文章:

    java - 在 Java 中从文档中获取 xml 字符串

    python - Hive自定义脚本是否允许2个或更多的reducer?

    hadoop - 从 SQL Server 导入,数据类型未正确转换

    hadoop - 将参数 "args"从主类传递给 Map 类

    xml - 声明为 DTD 的 DOCTYPE 如何影响 XSLT 转换?

    android - RecyclerView 中的 PercentFrameLayout (要求方形)未显示

    java - 在 Xml 中标记特定字符串

    java - hdfs namenode和datanode无法基于dfs.replication值启动

    python - Pydoop mapreduce "AttributeError: module ' wordcount_minimal' 没有属性 '__main__' "

    javascript - 将 mongodb mapReduce 结果写入文件