use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestVarRename method rename.
private void rename(String inputStr, String expectedStr, boolean reversable, Set<Var> constant) {
Op opOrig = SSE.parseOp(inputStr);
Op opExpected = SSE.parseOp(expectedStr);
Op opActual = Rename.renameVars(opOrig, constant);
if (DEV && !opExpected.equals(opActual)) {
System.err.println("**** Test: " + name.getMethodName());
System.err.println("::Expected::");
System.err.print(opExpected);
System.err.println("::Got::");
System.err.print(opActual);
}
assertEquals(opExpected, opActual);
if (reversable) {
// Undo.
Op opRebuilt = Rename.reverseVarRename(opActual, false);
assertEquals(opOrig, opRebuilt);
}
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestTransformPromoteTableEmpty method test.
public static void test(String input, Transform transform, String... output) {
Op opInput = SSE.parseOp(input);
test(opInput, transform, output);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestTransformPromoteTableEmpty method test.
public static void test(Op input, Transform transform, String... output) {
Op opOptimized = Transformer.transform(transform, input);
if (output == null) {
// No transformation.
Assert.assertEquals(input, opOptimized);
return;
}
Op op3 = SSE.parseOp(StrUtils.strjoinNL(output));
Assert.assertEquals(op3, opOptimized);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestVarRename method filter_not_exists_scoping_03.
// JENA-1275
@Test
public void filter_not_exists_scoping_03() {
//@formatter:off
Op orig = SSE.parseOp(StrUtils.strjoinNL("(project (?triangles ?openTriplets)", " (project (?openTriplets)", " (extend ((?openTriplets ?.0))", " (group () ((?.0 (count ?x)))", " (filter (notexists", " (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?z ?c ?x)))", " (quadpattern", " (quad <urn:x-arq:DefaultGraphNode> ?x ?a ?y)", " (quad <urn:x-arq:DefaultGraphNode> ?y ?b ?z)", " ))))))"));
Op expected = SSE.parseOp(StrUtils.strjoinNL("(project (?triangles ?openTriplets)", " (project (?openTriplets)", " (extend ((?openTriplets ?/.0))", " (group () ((?/.0 (count ?/x)))", " (filter (notexists", " (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?/z ?/c ?/x)))", " (quadpattern", " (quad <urn:x-arq:DefaultGraphNode> ?/x ?/a ?/y)", " (quad <urn:x-arq:DefaultGraphNode> ?/y ?/b ?/z)", " ))))))"));
//@formatter:on
Op transformed = TransformScopeRename.transform(orig);
Assert.assertEquals(transformed, expected);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class AbstractTestTransform method checkAlgebra.
public static void checkAlgebra(String algString, Transform additionalOptimizer, String opExpectedString) {
Op algebra = SSE.parseOp(algString);
// Safe copy
Op algebra1 = SSE.parseOp(algString);
Op optimized = Algebra.optimize(algebra);
if (additionalOptimizer != null)
optimized = Transformer.transform(additionalOptimizer, optimized);
Op opExpected = SSE.parseOp(opExpectedString != null ? opExpectedString : algString);
assertEquals(opExpected, optimized);
assertEquals("Modification of input during optimization", algebra1, algebra);
}
Aggregations