BytesWritable.setSize uses Integer.MAX_VALUE to initialize the internal array. On my environment, this causes an OOME
byte[Integer.MAX_VALUE-2] must be used to prevent this error.
Tested on OSX and CentOS 7 using Java version 1.8.0_131.
I noticed that java.util.ArrayList contains the following
BytesWritable.setSize should use something similar to prevent an OOME from occurring.