use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testOrElseXX.
@Test
public void testOrElseXX() {
// x || x
ParameterExpression x = Expressions.parameter(boolean.class, "x");
assertEquals("{\n return x;\n}\n", optimize(Expressions.orElse(x, x)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testAssign2.
@Test
public 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 testOptimizeTernaryAeqBAB.
@Test
public void testOptimizeTernaryAeqBAB() {
// a == b ? a : b
ParameterExpression a = Expressions.parameter(boolean.class, "a");
ParameterExpression b = Expressions.parameter(boolean.class, "b");
assertEquals("{\n return b;\n}\n", optimize(Expressions.condition(Expressions.equal(a, b), a, b)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testOptimizeTernaryAneqBBA.
@Test
public void testOptimizeTernaryAneqBBA() {
// a != b ? b : a
ParameterExpression a = Expressions.parameter(boolean.class, "a");
ParameterExpression b = Expressions.parameter(boolean.class, "b");
assertEquals("{\n return b;\n}\n", optimize(Expressions.condition(Expressions.notEqual(a, b), b, a)));
}
use of org.apache.calcite.linq4j.tree.ParameterExpression in project calcite by apache.
the class OptimizerTest method testNotEqualBoolFalse.
@Test
public void testNotEqualBoolFalse() {
// x != false
ParameterExpression x = Expressions.parameter(boolean.class, "x");
assertEquals("{\n return x;\n}\n", optimize(Expressions.notEqual(x, FALSE)));
}
Aggregations