【问题标题】:Hadoop- MapReduce - FixedInputFormat: java.io.IOException: Partial record found at the end of splitHadoop- MapReduce - FixedInputFormat: java.io.IOException: Partial record found at the end of split
【发布时间】:2017-10-30 19:43:10
【问题描述】:

您能否建议解决在运行 MapReduce 时出现在 FixedInputFormat 中的错误:Partial record found at the end of split

我正在分析为 Hive 自定义 FileInputFormat,并且正在研究来自以下 github 的 FixedInputFormathttps://github.com/apache/hadoop/tree/trunk/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/input

我复制了FixedInputFormatFixedRecordReader,并创建了一个映射器和驱动程序来测试它(0 个减速器)。

在 Mapper 中调用这个 FixedInputFormat 如下:

Configuration conf = new Configuration(true);
conf.set("fs.default.name", "file:///");
conf.setInt("fixedlengthinputformat.record.length",50);
job.setInputFormatClass(FixedLengthInputFormat.class);

数据文件如下(用3条记录测试):

   000yyy022222222xxxxxxx                       11111

splitsize 计算为 152 而不是 150,我收到以下错误:

java.lang.Exception: java.io.IOException: Partial record(length = 2) 在拆分结束时找到。 INFO customFixed.FixedLengthRecordReader:在拆分中期望 4 条记录,每条记录的长度为 50 字节,有效大小为 152 字节

我正在 Windows 中从 Intellij 运行它以进行分析。

这种方法有什么问题吗? 您能否建议解决此错误,我将不胜感激。

谢谢。

【问题讨论】:

    标签: java mapreduce hadoop2


    【解决方案1】:

    请看一下github提供的FixedInputFormat的代码。

    基本标准是每条记录的长度应相同。 这意味着文件中的每条记录的长度都应为“fixedlengthinputformat.record.length”。

    请验证输入文件,我确定你的一条记录超过50,准确来说是52

    记录阅读器一次读取 50 个字节,最后如果剩下 2 个字节,则无法将其解释为有效记录。

    【讨论】:

    • 我尝试使用不同的输入文件(这次是 txt),其中只有 3 条记录,每条记录的长度为 50,现在读取为 mapred.MapTask: Processing split: file:/C:anaCommon/src/main /resources/Input1.txt:0+154 - 部分记录中的 4 个字节
    • 我期待 150
    • 你能把 49 作为记录长度,把 \n 作为第 50 个。请确保您在第 4 行没有任何多余的 \n。如果使用某些文本编辑器,请确保分隔符合适。 github.com/apache/hadoop/blob/trunk/hadoop-mapreduce-project/…请检查分隔符没有特殊处理,它被视为您记录的一部分。
    • 您可以将事件设置为 51 为 fixedlengthinputformat.record.length 并从第 4 行删除 \n。使用 wc -c fileName 查看文件中存在多少个字符,它将计算 \n 也因此为您提供正确的数字。
    • 感谢 KrazyGautam。这就是我在想的。让我试试 Unix。
    猜你喜欢
    • 2022-12-02
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 2022-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多