@Test public void slice_order_to_topn_01() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 42" ; String opExpectedString = "(top (42 ?p ?o)\n" + " (bgp (triple ?s ?p ?o)))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_07() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT REDUCED * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 42" ; String opExpectedString = "(top (42 ?p ?o)\n" + " (distinct\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void distinct_order_by_application_01() { assertTrue(ARQ.isTrueOrUndef(ARQ.optOrderByDistinctApplication)) ; String queryString = "SELECT DISTINCT ?p { ?s ?p ?o } ORDER BY ?p"; String opExpectedString = "(order (?p)\n" + " (distinct\n" + " (project (?p)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tOrderByDistinctApplication, opExpectedString) ; }
@Test public void slice_order_to_topn_10() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT * { ?s ?p ?o } ORDER BY ?p ?o OFFSET 1 LIMIT 5" ; String opExpectedString = "(slice 1 _\n" + " (top (6 ?p ?o)\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void distinct_order_by_application_03() { // Evaluation reordering optimization doesn't apply if it's a SELECT * // Also per JENA-587 DISTINCT -> REDUCED transformation cannot apply either assertTrue(ARQ.isTrueOrUndef(ARQ.optOrderByDistinctApplication)) ; String queryString = "SELECT DISTINCT * { ?s ?p ?o } ORDER BY ?p"; String opExpectedString = " (distinct\n" + " (order (?p)\n" + " (bgp (triple ?s ?p ?o))))" ; testQuery(queryString, tOrderByDistinctApplication, opExpectedString) ; }
@Test public void reduced_order_by_application_01() { assertTrue(ARQ.isTrueOrUndef(ARQ.optOrderByDistinctApplication)) ; String queryString = "SELECT REDUCED ?p { ?s ?p ?o } ORDER BY ?p"; String opExpectedString = "(order (?p)\n" + " (reduced\n" + " (project (?p)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tOrderByDistinctApplication, opExpectedString) ; }
@Test public void slice_order_to_topn_06() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT DISTINCT * { ?s ?p ?o } ORDER BY ?p ?o OFFSET 24 LIMIT 42" ; String opExpectedString = "(slice 24 _\n" + " (top (66 ?p ?o)\n" + " (distinct\n" + " (bgp (triple ?s ?p ?o)))))" ; check(queryString, opExpectedString) ; }
@Test public void distinct_to_reduced_13() { // Per JENA-587 this is unsafe to transform since there is no ORDER BY assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } " ; String opExpectedString = "(distinct\n" + " (project (?p ?o)\n" + " (bgp (triple ?s ?p ?o))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }
@Test public void slice_order_to_topn_02() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 4242" ; String opExpectedString = "(slice _ 4242\n" + " (order (?p ?o)\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_03() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT * { ?s ?p ?o } ORDER BY ?p ?o OFFSET 4242 LIMIT 10" ; String opExpectedString = "(slice 4242 10\n" + " (order (?p ?o)\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_09() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT REDUCED * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 4242" ; String opExpectedString = "(slice _ 4242\n" + " (reduced\n" + " (order (?p ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; check(queryString, opExpectedString) ; }
@Test public void distinct_to_reduced_11() { // Per JENA-587 this is unsafe to transform since a non-project variable // appears before all the projected variables are seen in the ORDER BY assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } ORDER BY ?p ?s ?o" ; String opExpectedString = "(distinct\n" + " (project (?p ?o)\n" + " (order (?p ?s ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }
@Test public void distinct_to_reduced_12() { // Per JENA-587 this is unsafe to transform since a non-project variable // appears before all the projected variables are seen in the ORDER BY assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } ORDER BY ?s" ; String opExpectedString = "(distinct\n" + " (project (?p ?o)\n" + " (order (?s)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }
@Test public void slice_order_to_topn_05() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT DISTINCT * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 42" ; String opExpectedString = "(top (42 ?p ?o)\n" + " (distinct\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_08() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT DISTINCT * { ?s ?p ?o } ORDER BY ?p ?o LIMIT 4242" ; String opExpectedString = "(slice _ 4242\n" + " (distinct\n" + " (order (?p ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_11() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT ?s { ?s ?p ?o } ORDER BY ?p ?o OFFSET 1 LIMIT 5" ; String opExpectedString = "(slice 1 _\n" + " (project (?s)\n" + " (top (6 ?p ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; check(queryString, opExpectedString) ; }
@Test public void slice_order_to_topn_12() { assertTrue(ARQ.isTrueOrUndef(ARQ.optTopNSorting)) ; String queryString = "SELECT ?s { ?s ?p ?o } ORDER BY ?p ?o LIMIT 42" ; String opExpectedString = "(project (?s)\n" + " (top (42 ?p ?o)\n" + " (bgp (triple ?s ?p ?o))))" ; check(queryString, opExpectedString) ; }
@Test public void distinct_to_reduced_10() { // Per JENA-587 this is unsafe to transform since a non-project variable // appears before all the projected variables are seen in the ORDER BY assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } ORDER BY ?s ?p ?o" ; String opExpectedString = "(distinct\n" + " (project (?p ?o)\n" + " (order (?s ?p ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }
@Test public void distinct_to_reduced_09() { // Per JENA-587 this is safe to transform since all project variables // appear in the ORDER BY // Ordering of variables in the ORDER BY is irrelevant as long as they appear // before any non-projected variables assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } ORDER BY ?p ?o ?s" ; String opExpectedString = "(reduced\n" + " (project (?p ?o)\n" + " (order (?p ?o ?s)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }
@Test public void distinct_to_reduced_06() { // Per JENA-587 this is safe to transform since all project variables // appear in the ORDER BY // Ordering of variables in the ORDER BY is irrelevant as long as they appear // before any non-projected variables assertTrue(ARQ.isTrueOrUndef(ARQ.optDistinctToReduced)) ; String queryString = "SELECT DISTINCT ?p ?o { ?s ?p ?o } ORDER BY ?p ?o" ; String opExpectedString = "(reduced\n" + " (project (?p ?o)\n" + " (order (?p ?o)\n" + " (bgp (triple ?s ?p ?o)))))" ; testQuery(queryString, tDistinctToReduced, opExpectedString) ; }