Reputation: 4593
Upvotes: 0
Views: 290
Reputation: 33545
Here is the documentation for Mapper.Context. Given a particular job, some of the attributes like getJobID()
remains the same, while some of the attributes like getInputSplit()
might be different across maps within the same job.
Upvotes: 1
Reputation: 12020
Yes inside the same mapper it is the one and same context object in setup()
,map()
and cleanup()
.
As you may see these methods are called from the run()
, and that method goes like follows:
public void run(Context context) throws IOException, InterruptedException {
setup(context);
while (context.nextKeyValue()) {
map(context.getCurrentKey(), context.getCurrentValue(), context);
}
cleanup(context);
}
That should answer your points 1 and 2, and for point 3, you can override the run method to have more control as it's Javadoc suggests:
Expert users can override this method for more complete control over the execution of the Mapper.
And perhaps you do not need to keep a member field for context, but sure you can.
Also, while the object is same, it's properties' values mat be set or unset in any of the methods making it to be in a different state than it was when passed to another method (setup,map or cleanup).
Upvotes: 2