public String fromByteBuffer(ByteBuffer byteBuffer) {
if (byteBuffer == null) {
return null;
}
SnappyInputStream snappy = null;
ByteArrayOutputStream baos = null;
try {
ByteBuffer dup = byteBuffer.duplicate();
snappy = new SnappyInputStream(
new ByteArrayInputStream(dup.array(), 0,
dup.limit()));
baos = new ByteArrayOutputStream();
for (int value = 0; value != -1;) {
value = snappy.read();
if (value != -1) {
baos.write(value);
}
}
snappy.close();
baos.close();
return StringUtils.newStringUtf8(baos.toByteArray());
} catch (IOException e) {
throw new RuntimeException("Error decompressing column data", e);
} finally {
if (snappy != null) {
try {
snappy.close();
} catch (IOException e) {
}
}
if (baos != null) {
try {