use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class LikeExpressionTest method testExpression.
private boolean testExpression(String value, String expression, SortOrder sortorder) throws SQLException {
LiteralExpression v = LiteralExpression.newConstant(value, PVarchar.INSTANCE, sortorder);
LiteralExpression p = LiteralExpression.newConstant(expression, PVarchar.INSTANCE, sortorder);
List<Expression> children = Arrays.<Expression>asList(v, p);
LikeExpression e1 = ByteBasedLikeExpression.create(children, LikeType.CASE_SENSITIVE);
LikeExpression e2 = StringBasedLikeExpression.create(children, LikeType.CASE_SENSITIVE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean evaluated1 = e1.evaluate(null, ptr);
Boolean result1 = (Boolean) e1.getDataType().toObject(ptr);
assertTrue(evaluated1);
boolean evaluated2 = e2.evaluate(null, ptr);
Boolean result2 = (Boolean) e2.getDataType().toObject(ptr);
assertTrue(evaluated2);
assertEquals(result1, result2);
return result1;
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RegexpReplaceFunctionTest method evalExp.
private String evalExp(Expression exp) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean eval = exp.evaluate(null, ptr);
assertTrue(eval);
String res = (String) exp.getDataType().toObject(ptr);
return res;
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RegexpSplitFunctionTest method evalExp.
private String[] evalExp(Expression exp) throws SQLException {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean eval = exp.evaluate(null, ptr);
assertTrue(eval);
PhoenixArray evalRes = (PhoenixArray) exp.getDataType().toObject(ptr);
String[] res = (String[]) evalRes.getArray();
return res;
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RegexpSubstrFunctionTest method evalExp.
private String evalExp(Expression exp) {
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean eval = exp.evaluate(null, ptr);
assertTrue(eval);
String res = (String) exp.getDataType().toObject(ptr);
return res;
}
use of org.apache.hadoop.hbase.io.ImmutableBytesWritable in project phoenix by apache.
the class RoundFloorCeilExpressionsTest method testCeilDateExpressionWithMultiplier.
@Test
public void testCeilDateExpressionWithMultiplier() throws Exception {
Expression dateLiteral = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDate.INSTANCE);
Expression ceilDateExpression = CeilDateExpression.create(dateLiteral, TimeUnit.SECOND, 10);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
ceilDateExpression.evaluate(null, ptr);
Object result = ceilDateExpression.getDataType().toObject(ptr);
assertTrue(result instanceof Date);
Date resultDate = (Date) result;
assertEquals(DateUtil.parseDate("2012-01-01 14:25:30"), resultDate);
}
Aggregations