StreamXmlRecordReader在hadoop中无法正常工作

时间:2012-09-13 12:55:47

标签: xml hadoop-streaming

使用hadoop我试图在单独的节点中分割xml

<?xml version="1.0" encoding="UTF-8" ?>
<pages>
    <page>
            <title>Sourav</title>
    </page>
    <page>
            <title>Gaurav</title>
    </page>
    <page>
            <title>sachin</title>
    </page>
    <page>
            <title>Rahul</title>
    </page>
</pages>

<page>
        <title>abc</title>   
</page>

我按照命令

运行它
hadoop jar /usr/lib/hadoop-0.20-mapreduce/contrib/streaming/hadoop-streaming-2.0.0-mr1-cdh4.0.1.jar -inputreader "StreamXmlRecordReader,begin=<page>,end=</page>" -input /usr/root/xml  -output /usr/root/xmloutput

但是我得到了以下输出

而不是四个单个节点
<page>
    <title>Sourav</title>
</page> 
<page>
    <title>Gaurav</title>
</page> 
<page>
    <title>sachin</title>
</page> 
<page>
    <title>Rahul</title>
</page> 

<page>
    <title>sachin</title>
</page> 
<page>
    <title>Rahul</title>
</page> 

我做错了吗? 我很欣赏任何有关我做错的见解。

1 个答案:

答案 0 :(得分:2)

不,你没有做错任何事。

这是Hadoop Streaming中一个令人恼火的错误。

https://issues.apache.org/jira/browse/MAPREDUCE-577

这是0.20中的已知错误,但他们说它固定在0.22。我不知道这一点,但不幸的是它在1.0.4再次被打破。

与此同时,您可以将xml预处理为更好的流媒体。