package org.apache.hadoop.hive.serde2.lazy;
import java.nio.ByteBuffer;
import org.apache.cassandra.db.marshal.FloatType;
import org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyFloatObjectInspector;
/**
* CassandraLazyFloat parses the object into FloatWritable value.
*
*/
public class CassandraLazyFloat extends LazyFloat
{
public CassandraLazyFloat(LazyFloatObjectInspector oi) {
super(oi);
}
@Override
public void init(ByteArrayRef bytes, int start, int length) {
if ( length == 4 ) {
try {
ByteBuffer buf = ByteBuffer.wrap(bytes.getData(), start, length);
data.set(FloatType.instance.compose(buf));
isNull = false;
return;
} catch (Throwable ie) {
//we are unable to parse the data, try to parse it in the hive lazy way.
}
}
super.init(bytes, start, length);
}
}