Search in sources :

Example 1 with DoubleCompare

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());
    }
}
Also used : LongCompare(org.apache.hadoop.hive.accumulo.predicate.compare.LongCompare) StringCompare(org.apache.hadoop.hive.accumulo.predicate.compare.StringCompare) IntCompare(org.apache.hadoop.hive.accumulo.predicate.compare.IntCompare) DoubleCompare(org.apache.hadoop.hive.accumulo.predicate.compare.DoubleCompare) IntWritable(org.apache.hadoop.io.IntWritable) SerDeException(org.apache.hadoop.hive.serde2.SerDeException)

Aggregations

DoubleCompare (org.apache.hadoop.hive.accumulo.predicate.compare.DoubleCompare)1 IntCompare (org.apache.hadoop.hive.accumulo.predicate.compare.IntCompare)1 LongCompare (org.apache.hadoop.hive.accumulo.predicate.compare.LongCompare)1 StringCompare (org.apache.hadoop.hive.accumulo.predicate.compare.StringCompare)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 IntWritable (org.apache.hadoop.io.IntWritable)1