use of org.apache.jena.sparql.algebra.TransformCopy in project jena by apache.
the class TestTransformConstantFolding method test.
private void test(String input, String expected, ExprTransform transform) {
Op opOrig = SSE.parseOp(input);
Op opExpected = SSE.parseOp(expected != null ? expected : input);
Op opOptimized = Transformer.transform(new TransformCopy(), transform, opOrig);
Assert.assertEquals(opExpected, opOptimized);
}
use of org.apache.jena.sparql.algebra.TransformCopy in project jena by apache.
the class TestTransformFilterEquality method equality_expression_1.
// JENA -1202
@Test
public void equality_expression_1() {
// Need to fold to a string or URI to trigger equality.
Op op = SSE.parseOp("(filter (= ?o (+ 'a' 'b')) (bgp (?x <http://p2> ?o)))");
// Fold constants.
Op op1 = Transformer.transform(new TransformCopy(), new ExprTransformConstantFold(), op);
// Then apply filter-equality.
check(op1, t_equality, "(assign ((?o 'ab')) (bgp (?x <http://p2> 'ab')) )");
}
use of org.apache.jena.sparql.algebra.TransformCopy in project jena by apache.
the class TestTransformFilters method nested_02.
@Test
public void nested_02() {
Transform tableChanger = new TransformCopy() {
@Override
public Op transform(OpTable opTable) {
// Always a new object
return OpTable.create(opTable.getTable());
}
};
testOp("(filter (?A) (filter (?B) (table unit)))", tableChanger, "(filter (exprlist ?B ?A) (table unit))");
}
use of org.apache.jena.sparql.algebra.TransformCopy in project jena by apache.
the class ExprTransformConstantFold method transform.
@Override
public Expr transform(ExprFunctionOp funcOp, ExprList args, Op opArg) {
// Manually transform each argument
Op op = Transformer.transform(new TransformCopy(), this, funcOp.getGraphPattern());
ExprList newArgs = new ExprList();
for (int i = 0; i < args.size(); i++) {
Expr curr = args.get(i);
Expr newArg = ExprTransformer.transform(this, curr);
newArgs.add(newArg);
}
return funcOp.copy(newArgs, op);
}
Aggregations