Hadoop?????????????ú????MRUnit
???????????? ???????[ 2013/12/11 10:55:14 ] ????????
private MapReduceDriver<LongWritable?? Text?? Text?? TimeInfo?? Text?? LongWritable> mrDriver;
private Map mapper;
private Reduce reducer;
@Before
public void setUp() {
mapper = new Map();
reducer = new Reduce();
//??????ReduceMultipleOutputsDriver
mrDriver = new ReduceMultipleOutputsDriver<LongWritable?? Text?? Text??TimeInfo?? Text?? LongWritable>(mapper?? reducer);
}
@Test
public void testMapReduce_3record_1user() {
Text mapInputValue1 = new Text("……");
Text mapInputValue2 = new Text("……");
Text mapInputValue3 = new Text("……");
//??????????????????Map????????
//??reduce??????444??????????????2С?.
mrDriver.withInput(null?? mapInputValue1)
.withInput(null?? mapInputValue2)
.withInput(null?? mapInputValue3)
//???????"somePrefix"+444%8???collector???????????xxx
. withMutiOutput ("somePrefix"+444%8??new Text("444")??new LongWritable(2))
.runTest();
}
|
??????δ????????????
????????????????????MRUnit??????д????????????????????????????д??????У???ò??????????????????????????????????????????annotation?????JUnit runner???????MRUnit????????????
?????????????????????map??????????????????????????????????MRUnit???API?????
@RunWith(MRUnitJunit4TestClassRunner.class)
public class XXXMRUseAnnotationTest {
//???????????mrDriver????????????(??????)
@MapInputSet
@MapReduce(mapper = Map.class?? reducer = Reduce.class)
private MapReduceDriver<LongWritable?? Text?? Text?? TimeInfo?? Text?? LongWritable> mrDriver;
@Test
@MapInputSet("ConsignTimeMRUseAnnotationTest.txt")//?????????????????
public void testMapReduce_3record_1user() {
//??????д???????
mrDriver. withMutiOutput ("somePrefix"+444%8??new Text("444")??new LongWritable(2))
.runTest();
}
}
|