use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class AbstractTestTransform method check.
private static void check(Op opToOptimize, String opExpectedString) {
Op opOptimize = Algebra.optimize(opToOptimize);
Op opExpected = SSE.parseOp(opExpectedString);
if (false) {
// Hook for more detail during development.
boolean b = Objects.equals(opExpected, opOptimize);
if (!b) {
System.err.println("** Input:");
System.err.print(opToOptimize);
System.err.println("** Expected:");
System.err.print(opExpected);
System.err.println("** Actual:");
System.err.print(opOptimize);
System.err.println("-------------------");
}
}
assertEquals(opExpected, opOptimize);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestOptimizer method combine_assign_04.
@Test
public void combine_assign_04() {
String opString = StrUtils.strjoinNL("(assign ((?x 2))", " (assign ((?y 3))", " (distinct", " (assign ((?a 'A') (?b 'B'))", " (assign ((?c 'C'))", " (table unit)", " )))))");
String opExpectedString = StrUtils.strjoinNL("(assign ((?y 3) (?x 2))", " (distinct", " (assign ((?c 'C') (?a 'A') (?b 'B'))", " (table unit))))");
Op op = SSE.parseOp(opString);
check(op, new TransformExtendCombine(), opExpectedString);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestAlgebraTranslate method test.
protected void test(String qs, String... y) {
qs = "SELECT * {\n" + qs + "\n}";
Query query = QueryFactory.create(qs, Syntax.syntaxARQ);
String opStr = StrUtils.strjoinNL(y);
Op opExpected = SSE.parseOp(opStr);
Op opActual = this.getGenerator().compile(query);
assertEquals(opExpected, opActual);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestOpAsQuery method test_equivalentQuery.
// There 3 classes of transformations: there are 3 main test operations.
// test_roundTripQuery: The same query is recovered from OpAsQuery
// test_roundTripAlegbra: Different queries with the same alegra forms
// test_equivalentQuery: Different equivalent queries - same answers, different algebra.
// test_algebraToQuery: algebra to query (e.g. optimization shapes)
//
// test_roundTripQuery is test_equivalentQuery with same input and expected.
// + quad variants.
public static void test_equivalentQuery(String input, String expected) {
Query orig = QueryFactory.create(input, Syntax.syntaxSPARQL_11);
Op toReconstruct = Algebra.compile(orig);
Query got = OpAsQuery.asQuery(toReconstruct);
Query result = QueryFactory.create(expected, Syntax.syntaxSPARQL_11);
assertEquals(result, got);
}
use of org.apache.jena.sparql.algebra.Op in project jena by apache.
the class TestPattern2Join method test4.
private static void test4(String pattern, String... joinForm) {
Query q = QueryFactory.create("PREFIX : <http://example/> SELECT * " + pattern);
Op op = Algebra.compile(q.getQueryPattern());
op = Algebra.toQuadForm(op);
test(op, joinForm);
}
Aggregations