Search in sources :

Example 1 with CbrtFunction

use of org.apache.phoenix.expression.function.CbrtFunction in project phoenix by apache.

the class CbrtFunctionTest method testExpression.

private static void testExpression(LiteralExpression literal, double expected) throws SQLException {
    List<Expression> expressions = Lists.newArrayList((Expression) literal);
    Expression cbrtFunction = new CbrtFunction(expressions);
    ImmutableBytesWritable ptr = new ImmutableBytesWritable();
    cbrtFunction.evaluate(null, ptr);
    Double result = (Double) cbrtFunction.getDataType().toObject(ptr, cbrtFunction.getSortOrder());
    assertTrue(Math.abs(result.doubleValue() - expected) <= 1e-9);
}
Also used : CbrtFunction(org.apache.phoenix.expression.function.CbrtFunction) ImmutableBytesWritable(org.apache.hadoop.hbase.io.ImmutableBytesWritable) PUnsignedDouble(org.apache.phoenix.schema.types.PUnsignedDouble) PDouble(org.apache.phoenix.schema.types.PDouble)

Aggregations

ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)1 CbrtFunction (org.apache.phoenix.expression.function.CbrtFunction)1 PDouble (org.apache.phoenix.schema.types.PDouble)1 PUnsignedDouble (org.apache.phoenix.schema.types.PUnsignedDouble)1