You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Raymond Jennings III <ra...@yahoo.com> on 2010/01/12 17:04:44 UTC

Obtaining name of file in map task

I am trying to determine what the name of the file that is being used for the map task.  I am trying to use the setup() method to read the input file with:

public void setup(Context context) {

    	Configuration conf = context.getConfiguration();
    	String inputfile = conf.get("map.input.file");
..

But inputfile is always null.  Anyone have a pointer on how to do this?  Thanks.


      

Re: Obtaining name of file in map task

Posted by Farhan Husain <fa...@csebuet.org>.
The bug report here
<https://issues.apache.org/jira/browse/HADOOP-5973>tells that it is
not a bug at all. Hopefully the documentation will be
updated as mentioned in the comment.

On Wed, Jan 20, 2010 at 2:19 PM, Farhan Husain <fa...@csebuet.org>wrote:

> You can try to following code:
>
> FileSplit fileSplit = (FileSplit) context.getInputSplit();
> String sFileName = fileSplit.getPath().getName();
>
>
> On Tue, Jan 12, 2010 at 10:04 AM, Raymond Jennings III <
> raymondjiii@yahoo.com> wrote:
>
>> I am trying to determine what the name of the file that is being used for
>> the map task.  I am trying to use the setup() method to read the input file
>> with:
>>
>> public void setup(Context context) {
>>
>>        Configuration conf = context.getConfiguration();
>>        String inputfile = conf.get("map.input.file");
>> ..
>>
>> But inputfile is always null.  Anyone have a pointer on how to do this?
>>  Thanks.
>>
>>
>>
>>
>

Re: Obtaining name of file in map task

Posted by Farhan Husain <fa...@csebuet.org>.
You can try to following code:

FileSplit fileSplit = (FileSplit) context.getInputSplit();
String sFileName = fileSplit.getPath().getName();

On Tue, Jan 12, 2010 at 10:04 AM, Raymond Jennings III <
raymondjiii@yahoo.com> wrote:

> I am trying to determine what the name of the file that is being used for
> the map task.  I am trying to use the setup() method to read the input file
> with:
>
> public void setup(Context context) {
>
>        Configuration conf = context.getConfiguration();
>        String inputfile = conf.get("map.input.file");
> ..
>
> But inputfile is always null.  Anyone have a pointer on how to do this?
>  Thanks.
>
>
>
>