- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: http://mrunit.apache.org/
- 软件文档: https://cwiki.apache.org/confluence/display/MRUNIT/MRUnit+Tutorial
软件介绍
MRUnit是由Couldera公司开发的专门针对 Hadoop中编写MapReduce单元测试的框架,基本原理是JUnit4和 EasyMock。MR就是Map和Reduce的缩写。MRUnit框架非常精简,其核心的单元测试依赖于JUnit。而且MRUnit实现了一套 Mock对象来控制OutputCollector的操作,从而可以拦截OutputCollector的输出,和我们的期望结果进行比较,达到自动断言 的目的。
有了MRUnit,对MR程序做重构的时候,只要明确输入和输出,就可以写出单元测试,并且在放到群集校验前进行试验,从而节省时间和资源,也 能更快的定位到问题。而进行重构的话,只要写得足够详细的单元测试都是绿色的话,那么基本就可以保证在群集运行的结果也是正常的。
MRUnit不在Apache标准的Hadoop的发行版中,而是在Couldera公司的增强版本中hadoop- 0.20.1+133.tar.gz的contrib\mrunit\hadoop-0.20.1+169.56-mrunit.jar,已经贴在附件 中。只要把它和Junit4的jar添加到Hadoop程序项目的classpath中,就可以使用MRUnit了。
MRUnit包含四种 Driver:MapDriver,ReduceDriver,MapReduceDriver,PipelineMapReduceDriver。可以 根据自己的需要选择合适的Driver。
给出一个Reduce的很简单例子,Reduce的逻辑就是把Value中的各个值相加。
public class ExtractKeywordTest {private Reducer<Text, Text, Text, Text> reducer;private ReduceDriver<Text, Text, Text, Text> reduceDriver;@Beforepublic void setUp() throws Exception {reducer = new ExtractKeywordAcookie.Reduce();reduceDriver = new ReduceDriver<Text, Text, Text, Text>(reducer);}@Testpublic void testReduce() {List<Text> values = new ArrayList<Text>();values.add(new Text(1.0_0.1));values.add(new Text(2.0_0.2));values.add(new Text(3.0_0.3));reduceDriver.withInput(new Text(20100106_00_IBM), values).withOutput(new Text(20100106_00_IBM_6.00_0.60_), null).runTest();}
Learning PHP, MySQL, and JavaScript
Robin Nixon / O'Reilly Media / 2009-7-21 / USD 39.99
Learn how to create responsive, data-driven websites with PHP, MySQL, and JavaScript - whether or not you know how to program. This simple, streamlined guide explains how the powerful combination of P......一起来看看 《Learning PHP, MySQL, and JavaScript》 这本书的介绍吧!
