Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Cannot Reproduce
-
0.2.1
-
None
-
Not sure environment matters for this one but Ubuntu
Description
When using CassandraStore and GoraMapper to retrieve data previously stored in Cassandra, a BufferUnderflowException is being thrown in method fromByteBuffer() in class CassandraColumn. This results in a complete failure of the hadoop job trying to use the Cassandra data.
The problem seems to be caused by an invalid assumption in the (de) Serializer logic. Serializers assume that the bytes in a ByteBuffer to be deserialized start at offset 0 (zero) in the ByteBuffer's internal buffer. In fact, there are times when a ByteBuffer passed back from the Hector/Thrift API will have its data start at a non-zero offset in its buffer. When serializers are given these non-zero offset ByteBuffers an exception, usually BufferUnderflowException, is thrown.
The suggested fix is to use the TbaseHelper class from Cassandra/Thrift:
import org.apache.thrift.TBaseHelper;
protected Object fromByteBuffer(Schema schema, ByteBuffer byteBuffer) {
Object value = null;
Serializer serializer = GoraSerializerTypeInferer.getSerializer(schema);
if (serializer == null)
else
{ ByteBuffer corrected = TBaseHelper.rightSize(byteBuffer); value = serializer.fromByteBuffer(corrected); } return value;
}