You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mrunit.apache.org by 吴涌波 <wu...@mediav.com> on 2012/10/16 04:10:41 UTC

how to test with many input files and relatived output

 

Hi, 

I get the file name of my input file in my map function, and output
something relatived with it:

Like :

Map(,,,,){

       filename = getfileName();

         If(filename.equal(“a.file”)){

                   context.write(new IntWritable(1), somedata);

         }else{

                   context.write(new IntWritable(2), somedata);

         }

}

 

Could you please tell me how to test it in detail?

Thanks;

 


YongBo Wu

 


Re: how to test with many input files and relatived output

Posted by Bertrand Dechoux <de...@gmail.com>.
Hi,

In the 0.9, the filename is hardcoded but this is configurable in the
soon-to-be 1.0 release.
https://issues.apache.org/jira/browse/MRUNIT-118

If you do not want to wait, you check out the trunk of course.


As for the test, it looks something like

    MapDriver.newMapDriver(new WordCountMapper())
            .withInput(new LongWritable(1), new Text("word1 word2 "))
            .withOutput(buildExpectedOutput(new Text("word1"), new
LongWritable(1)))
            .withOutput(buildExpectedOutput(new Text("word2"), new
LongWritable(1))
            .runTest();

Regards

Bertrand

On Tue, Oct 16, 2012 at 4:10 AM, 吴涌波 <wu...@mediav.com> wrote:

>  ** **
>
> Hi, ****
>
> I get the file name of my input file in my map function, and output
> something relatived with it:****
>
> Like :****
>
> Map(,,,,){****
>
>        filename = getfileName();****
>
>          If(filename.equal(“a.file”)){****
>
>                    context.write(new IntWritable(1), somedata);****
>
>          }else{****
>
>                    context.write(new IntWritable(2), somedata);****
>
>          }****
>
> }****
>
> ** **
>
> Could you please tell me how to test it in detail?****
>
> Thanks;****
>
> ** **
>
> *YongBo Wu***
>
> ** **
>



-- 
Bertrand Dechoux