Clueless Gorilla
Clueless Gorilla

Reputation: 1229

Run Hadoop Mapper in Sequence

I have this task with multiple mappers, Map 1 and Map 2. I need it to be executed specifically in this way: Map1->Map2->Reducer. How do I do so? Thanks you very much!

Upvotes: 0

Views: 311

Answers (1)

WestCoastProjects
WestCoastProjects

Reputation: 63221

Please take a look at the ChainMapper

http://hadoop.apache.org/docs/stable2/api/org/apache/hadoop/mapred/lib/ChainMapper.html

The ChainMapper class allows to use multiple Mapper classes within a single Map task.

UPDATE OP was concerned the maps are not sequential. That is not the case - as verified in the source code comments and in the code itself:

Mapper mapper = chain.getFirstMap();
if (mapper != null) {
  mapper.map(key, value, chain.getMapperCollector(0, output, reporter),
             reporter);
}

Upvotes: 4

Related Questions