Status: Patch Available
Affects Version/s: None
Fix Version/s: None
Release Note:Throw an Exception in the most common error scenario present in many FileInputFormat derivatives that do not override isSplitable.
When implementing a custom derivative of FileInputFormat we ran into the effect that a large Gzipped input file would be processed several times.
A near 1GiB file would be processed around 36 times in its entirety. Thus producing garbage results and taking up a lot more CPU time than needed.
It took a while to figure out and what we found is that the default implementation of the isSplittable method in org.apache.hadoop.mapreduce.lib.input.FileInputFormat is simply "return true;".
This is a very unsafe default and is in contradiction with the JavaDoc of the method which states: "Is the given filename splitable? Usually, true, but if the file is stream compressed, it will not be. " . The actual implementation effectively does "Is the given filename splitable? Always true, even if the file is stream compressed using an unsplittable compression codec. "
For our situation (where we always have Gzipped input) we took the easy way out and simply implemented an isSplittable in our class that does "return false; "
Now there are essentially 3 ways I can think of for fixing this (in order of what I would find preferable):
- Implement something that looks at the used compression of the file (i.e. do migrate the implementation from TextInputFormat to FileInputFormat). This would make the method do what the JavaDoc describes.
- "Force" developers to think about it and make this method abstract.
- Use a "safe" default (i.e. return false)