InputSplit[] sorted = new InputSplit[NUM_MAPS];
splits.toArray(sorted);
Builder.sortSplits(sorted);
Step0Context context = new Step0Context(new Step0Mapper(), job.getConfiguration(),
new TaskAttemptID(), NUM_MAPS);
for (int p = 0; p < NUM_MAPS; p++) {
InputSplit split = sorted[p];
RecordReader<LongWritable, Text> reader = input.createRecordReader(split,
context);
reader.initialize(split, context);
Step0Mapper mapper = new Step0Mapper();
mapper.configure(p);
Long firstKey = null;
int size = 0;
while (reader.nextKeyValue()) {
LongWritable key = reader.getCurrentKey();
if (firstKey == null) {
firstKey = key.get();
}
mapper.map(key, reader.getCurrentValue(), context);
size++;
}
mapper.cleanup(context);
// validate the mapper's output
assertEquals(p, context.keys[p]);
assertEquals(firstKey.longValue(), context.values[p].getFirstId());
assertEquals(size, context.values[p].getSize());