mapreduce测试

import
import
import
import
org.apache.hadoop.io.LongWritable;
org.apache.hadoop.io.Text;
org.apache.hadoop.mrunit.mapreduce.MapDriver;
org.junit.Test;
public class MyMapperTest {
@Test
public void processesValidRecord() throws Exception {
Text value = new Text();
value.set("201001 1003
abc");
TextPair textPair = new TextPair();
textPair.setKey1(new Text("1003"));
textPair.setKey2(new Text("1"));
Text outValue = new Text("201001" + "\t" + "abc");
new MapDriver<LongWritable, Text, TextPair, Text>()
.withMapper(new MyMapper())
.withInput(new LongWritable(0), value)
.withOutput(textPair, outValue).runTest();
}
}
这个是对MyMapper中有关data.info部分的测试,这里刚开始的时候,在写
TextPair类的时候,并没有覆写
@Override
public int hashCode() {
// TODO Auto-generated method stub
return Integer.parseInt(this.getKey1().toString()) * 157
+ Integer.parseInt(this.getKey2().toString());
}
@Override
public boolean equals(Object obj) {

TextPair o = (TextPair) obj;
return this.getKey1().equals(o.key1) && this.getKey2().equals(o.key2);
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getKey1().toString() + "\t" + this.getKey2().toString();
}
上面这3个方法,导致怎么测试都不能成功,即使结果完全一样也没有通过
测试,后来,覆写之后就成功了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值