<legend id='lM52e'><style id='lM52e'><dir id='lM52e'><q id='lM52e'></q></dir></style></legend>
      <i id='lM52e'><tr id='lM52e'><dt id='lM52e'><q id='lM52e'><span id='lM52e'><b id='lM52e'><form id='lM52e'><ins id='lM52e'></ins><ul id='lM52e'></ul><sub id='lM52e'></sub></form><legend id='lM52e'></legend><bdo id='lM52e'><pre id='lM52e'><center id='lM52e'></center></pre></bdo></b><th id='lM52e'></th></span></q></dt></tr></i><div id='lM52e'><tfoot id='lM52e'></tfoot><dl id='lM52e'><fieldset id='lM52e'></fieldset></dl></div>

      <small id='lM52e'></small><noframes id='lM52e'>

    1. <tfoot id='lM52e'></tfoot>
        • <bdo id='lM52e'></bdo><ul id='lM52e'></ul>

        多行文本到一个地图

        时间:2023-09-26
      1. <legend id='XL2AB'><style id='XL2AB'><dir id='XL2AB'><q id='XL2AB'></q></dir></style></legend>

            <bdo id='XL2AB'></bdo><ul id='XL2AB'></ul>
            • <i id='XL2AB'><tr id='XL2AB'><dt id='XL2AB'><q id='XL2AB'><span id='XL2AB'><b id='XL2AB'><form id='XL2AB'><ins id='XL2AB'></ins><ul id='XL2AB'></ul><sub id='XL2AB'></sub></form><legend id='XL2AB'></legend><bdo id='XL2AB'><pre id='XL2AB'><center id='XL2AB'></center></pre></bdo></b><th id='XL2AB'></th></span></q></dt></tr></i><div id='XL2AB'><tfoot id='XL2AB'></tfoot><dl id='XL2AB'><fieldset id='XL2AB'></fieldset></dl></div>

            • <tfoot id='XL2AB'></tfoot>
                  <tbody id='XL2AB'></tbody>

              • <small id='XL2AB'></small><noframes id='XL2AB'>

                  本文介绍了多行文本到一个地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直在尝试使用 Hadoop 将 N 行数发送到单个映射.我不需要已经拆分行.

                  I've been trying to use Hadoop to send N amount of lines to a single mapping. I don't require for the lines to be split already.

                  我尝试使用 NLineInputFormat,但是它一次将 N 行文本从数据发送到每个映射器 [在第 N 行之后放弃].

                  I've tried to use NLineInputFormat, however that sends N lines of text from the data to each mapper one line at a time [giving up after the Nth line].

                  我已尝试设置该选项,它只需要 N 行输入,一次将 1 行发送到每个地图:

                  I have tried to set the option and it only takes N lines of input sending it at 1 line at a time to each map:

                      job.setInt("mapred.line.input.format.linespermap", 10);
                  

                  我找到了一个邮件列表,建议我重写 LineRecordReader::next,但这并不是那么简单,因为内部数据成员都是私有的.

                  I've found a mailing list recommending me to override LineRecordReader::next, however that is not that simple, as that the internal data members are all private.

                  我刚刚检查了 NLineInputFormat 的源代码,它对 LineReader 进行了硬编码,因此覆盖无济于事.

                  I've just checked the source for NLineInputFormat and it hard codes LineReader, so overriding will not help.

                  另外,顺便说一句,我使用 Hadoop 0.18 来兼容 Amazon EC2 MapReduce.

                  Also, btw I'm using Hadoop 0.18 for compatibility with the Amazon EC2 MapReduce.

                  推荐答案

                  你必须实现你自己的输入格式.您还可以定义自己的唱片阅读器.

                  You have to implement your own input format. You also have the possibility to define your own record reader then.

                  不幸的是,您必须定义一个 getSplits() 方法.在我看来,这将比实现记录读取器更难:这个方法必须实现一个逻辑来分块输入数据.

                  Unfortunately you have to define a getSplits()-method. In my opinion this will be harder than implementing the record reader: This method has to implement a logic to chunk the input data.

                  请参阅Hadoop - 权威指南"的以下摘录(我会一直推荐的一本好书!):

                  See the following excerpt from "Hadoop - The definitive guide" (a great book I would always recommend!):

                  界面如下:

                  public interface InputFormat<K, V> {
                    InputSplit[] getSplits(JobConf job, int numSplits) throws IOException;
                    RecordReader<K, V> getRecordReader(InputSplit split,
                                                       JobConf job, 
                                                       Reporter reporter) throws IOException;
                  }
                  

                  JobClient 调用 getSplits() 方法,传递所需数量的地图任务作为 numSplits 参数.这个数字被视为一个提示,作为 InputFormat impl-mentations 可以自由地将不同数量的拆分返回到指定的数量数分裂.计算完拆分后,客户端将它们发送到 jobtracker,后者使用它们的存储位置来安排地图任务以在 tasktracker 上处理它们.

                  The JobClient calls the getSplits() method, passing the desired number of map tasks as the numSplits argument. This number is treated as a hint, as InputFormat imple- mentations are free to return a different number of splits to the number specified in numSplits. Having calculated the splits, the client sends them to the jobtracker, which uses their storage locations to schedule map tasks to process them on the tasktrackers.

                  在 tasktracker 上,map 任务将拆分传递给 getRecordReader() 方法InputFormat 以获取该拆分的 RecordReader.RecordReader 只不过是记录的迭代器,map 任务使用一个迭代器生成记录键值对,它传递给 map 函数.代码片段(基于 MapRunner 中的代码)说明了这个想法:

                  On a tasktracker, the map task passes the split to the getRecordReader() method on InputFormat to obtain a RecordReader for that split. A RecordReader is little more than an iterator over records, and the map task uses one to generate record key-value pairs, which it passes to the map function. A code snippet (based on the code in MapRunner) illustrates the idea:

                  K key = reader.createKey();
                  V value = reader.createValue();
                  while (reader.next(key, value)) {
                    mapper.map(key, value, output, reporter);
                  } 
                  

                  这篇关于多行文本到一个地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Gradle 传递依赖排除未按预期工作.(我如何摆脱 下一篇:/bin/bash:/bin/java: 在 MacOS 的 Yarn 应用程序中没有这

                  相关文章

                  最新文章

                1. <tfoot id='WdaB8'></tfoot>

                  <small id='WdaB8'></small><noframes id='WdaB8'>

                    1. <i id='WdaB8'><tr id='WdaB8'><dt id='WdaB8'><q id='WdaB8'><span id='WdaB8'><b id='WdaB8'><form id='WdaB8'><ins id='WdaB8'></ins><ul id='WdaB8'></ul><sub id='WdaB8'></sub></form><legend id='WdaB8'></legend><bdo id='WdaB8'><pre id='WdaB8'><center id='WdaB8'></center></pre></bdo></b><th id='WdaB8'></th></span></q></dt></tr></i><div id='WdaB8'><tfoot id='WdaB8'></tfoot><dl id='WdaB8'><fieldset id='WdaB8'></fieldset></dl></div>
                      • <bdo id='WdaB8'></bdo><ul id='WdaB8'></ul>

                      <legend id='WdaB8'><style id='WdaB8'><dir id='WdaB8'><q id='WdaB8'></q></dir></style></legend>