use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testEqualSameExpr.
@Test
void testEqualSameExpr() {
// x == x
ParameterExpression x = Expressions.parameter(int.class, "x");
assertEquals("{\n return true;\n}\n", optimize(Expressions.equal(x, x)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testAssign2.
@Test
void testAssign2() {
// long x = 0;
// final long y = System.currentTimeMillis();
// if (System.currentTimeMillis() > 0) {
// x = y;
// }
//
// Make sure we don't fold two calls to System.currentTimeMillis into one.
final ParameterExpression x_ = Expressions.parameter(long.class, "x");
final ParameterExpression y_ = Expressions.parameter(long.class, "y");
final Method mT = Linq4j.getMethod("java.lang.System", "currentTimeMillis");
final ConstantExpression zero = Expressions.constant(0L);
assertThat(optimize(Expressions.block(Expressions.declare(0, x_, zero), Expressions.declare(Modifier.FINAL, y_, Expressions.call(mT)), Expressions.ifThen(Expressions.greaterThan(Expressions.call(mT), zero), Expressions.statement(Expressions.assign(x_, y_))))), equalTo("{\n" + " long x = 0L;\n" + " if (System.currentTimeMillis() > 0L) {\n" + " x = System.currentTimeMillis();\n" + " }\n" + "}\n"));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testEqualDifferentExpr.
@Test
void testEqualDifferentExpr() {
// x == y
ParameterExpression x = Expressions.parameter(int.class, "x");
ParameterExpression y = Expressions.parameter(int.class, "y");
assertEquals("{\n return x == y;\n}\n", optimize(Expressions.equal(x, y)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testNotEqualDifferentExpr.
@Test
void testNotEqualDifferentExpr() {
// x != y
ParameterExpression x = Expressions.parameter(int.class, "x");
ParameterExpression y = Expressions.parameter(int.class, "y");
assertEquals("{\n return x != y;\n}\n", optimize(Expressions.notEqual(x, y)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testNotEqualPrimitiveNull.
@Test
void testNotEqualPrimitiveNull() {
// (int) x == null
ParameterExpression x = Expressions.parameter(int.class, "x");
assertEquals("{\n return true;\n}\n", optimize(Expressions.notEqual(x, NULL)));
}
Aggregations