hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Zhang <zjf...@gmail.com>
Subject Re: Is it pissible get a number of mapper tasks?
Date Sat, 04 Dec 2010 01:46:01 GMT
You can use the following code to get the number of mapper task

	InputFormat inputForamt = ReflectionUtils.newInstance(
						context.getInputFormatClass(),
						context.getConfiguration());
	int num = inputForamt.getSplits(context).size();


and you'd better put it in setup method of your Reducer,

BTW, why not take task attempt id context.getTaskAttemptID() as the
prefix of unique id ? The task attempt id for each task should be
different



On Sat, Dec 4, 2010 at 9:11 AM, Jason <urgisb@gmail.com> wrote:
> In my mapper code I need to know the total number of mappers which is the same as number
of input splits.
> (I need it for unique int Id generation)
>
>
> Basically Im looking for an analog of context.getNumReduceTasks() but can't find it.
>
>
> Thanks
>
>
>
>>
>



-- 
Best Regards

Jeff Zhang

Mime
View raw message