<tfoot id='xJX3O'></tfoot>
      • <bdo id='xJX3O'></bdo><ul id='xJX3O'></ul>
    1. <small id='xJX3O'></small><noframes id='xJX3O'>

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

        <i id='xJX3O'><tr id='xJX3O'><dt id='xJX3O'><q id='xJX3O'><span id='xJX3O'><b id='xJX3O'><form id='xJX3O'><ins id='xJX3O'></ins><ul id='xJX3O'></ul><sub id='xJX3O'></sub></form><legend id='xJX3O'></legend><bdo id='xJX3O'><pre id='xJX3O'><center id='xJX3O'></center></pre></bdo></b><th id='xJX3O'></th></span></q></dt></tr></i><div id='xJX3O'><tfoot id='xJX3O'></tfoot><dl id='xJX3O'><fieldset id='xJX3O'></fieldset></dl></div>
      1. 如何对自定义 RecordReader 和 InputFormat 类进行单元

        时间:2023-09-27

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

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

                • 本文介绍了如何对自定义 RecordReader 和 InputFormat 类进行单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我开发了一个 map-reduce 程序.我编写了自定义 RecordReaderInputFormat 类.

                  I have developed one map-reduce program. I have written custom RecordReader and InputFormat classes.

                  我正在使用 MR UnitMockito 对 mapper 和 reducer 进行单元测试.

                  I am using MR Unit and Mockito for unit testing of mapper and reducer.

                  我想知道如何对自定义 RecordReaderInputFormat 类进行单元测试?测试这些类的首选方法是什么?

                  I would like to know how to unit test custom RecordReader and InputFormat classes? What is the most preferred way to test these classes?

                  推荐答案

                  感谢user7610

                  来自answer

                  import org.apache.hadoop.conf.Configuration;
                  import org.apache.hadoop.fs.Path;
                  import org.apache.hadoop.mapreduce.InputFormat;
                  import org.apache.hadoop.mapreduce.RecordReader;
                  import org.apache.hadoop.mapreduce.TaskAttemptContext;
                  import org.apache.hadoop.mapreduce.TaskAttemptID;
                  import org.apache.hadoop.mapreduce.lib.input.FileSplit;
                  import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
                  import org.apache.hadoop.util.ReflectionUtils;
                  import java.io.File;
                  
                  Configuration conf = new Configuration(false);
                  conf.set("fs.default.name", "file:///");
                  
                  File testFile = new File("path/to/file");
                  Path path = new Path(testFile.getAbsoluteFile().toURI());
                  FileSplit split = new FileSplit(path, 0, testFile.length(), null);
                  
                  InputFormat inputFormat = ReflectionUtils.newInstance(MyInputFormat.class, conf);
                  TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID());
                  RecordReader reader = inputFormat.createRecordReader(split, context);
                  
                  reader.initialize(split, context);
                  

                  这篇关于如何对自定义 RecordReader 和 InputFormat 类进行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Hadoop 选项没有任何效果(mapreduce.input.lineinputform 下一篇:如何(在 Hadoop 中)将数据放入正确类型的 map 和

                  相关文章

                  最新文章

                  • <bdo id='Ortc6'></bdo><ul id='Ortc6'></ul>

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

                  1. <legend id='Ortc6'><style id='Ortc6'><dir id='Ortc6'><q id='Ortc6'></q></dir></style></legend>
                      <tfoot id='Ortc6'></tfoot>