use of org.apache.hadoop.hive.accumulo.predicate.compare.DoubleCompare in project hive by apache.
the class PushdownTuple method getConstantAsBytes.
/**
* @return byte [] value from writable.
* @throws SerDeException
*/
public byte[] getConstantAsBytes(Writable writable) throws SerDeException {
if (pCompare instanceof StringCompare) {
return writable.toString().getBytes();
} else if (pCompare instanceof DoubleCompare) {
byte[] bts = new byte[8];
double val = ((DoubleWritable) writable).get();
ByteBuffer.wrap(bts).putDouble(val);
return bts;
} else if (pCompare instanceof IntCompare) {
byte[] bts = new byte[4];
int val = ((IntWritable) writable).get();
ByteBuffer.wrap(bts).putInt(val);
return bts;
} else if (pCompare instanceof LongCompare) {
byte[] bts = new byte[8];
long val = ((LongWritable) writable).get();
ByteBuffer.wrap(bts).putLong(val);
return bts;
} else {
throw new SerDeException("Unsupported primitive category: " + pCompare.getClass().getName());
}
}
Aggregations