[
https://issues.apache.org/jira/browse/JENA-1945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17187021#comment-17187021
]
Andy Seaborne commented on JENA-1945:
-------------------------------------
Hi Claus,
(c) is what the union graph does. The advantage of the union graph is that is
pushes the union work into graph find so cardinality can be handled correctly.
It is efficient in TDB1 and TDB2.
There is also a general purpose {{GraphUnionRead}} which is the union graph
over named graphs in a dataset (or any collection of graphs).
This is how property paths get handled correctly - run over a graph that
calculates the union and ensures {{(?s ?p ?o)}} has no duplicates. Because
paths can themselves have duplicates, it is necessary to get the right
cardinality in graph access of the union graph separately from the path-caused
ones.
{noformat}
(?s ?p ?o) => (<urn:x-arq:UnionGraph> ?s ?p ?o)
{noformat}
and evaluation knows about the union graph. In triples, because
{{urn:x-arq:UnionGraph}} uses {{DatasetGraph.getUnionGraph()}}; in quads,
because it is in the {{OpExecutorTDB}}. When {{Algebra.unionDefaultGraph}} was
written {{DatasetGraph}} did not have {{getUnionGraph()}}.
Paths should work in all cases.
{noformat}
// Quads, rename to union graph
Op op1 = Algebra.compile(QueryFactory.create("SELECT * { ?s
<http://example/p> ?z . ?z <http://example/q> ?o }"));
Op op2 = Algebra.toQuadForm(op1);
System.out.println(op2);
Transform transform = new
TransformGraphRename(Quad.defaultGraphNodeGenerated, Quad.unionGraph);
Op op3 = Transformer.transform(transform, op2);
System.out.println(op3);
Query q = OpAsQuery.asQuery(op3);
System.out.println(q);
{noformat}
{noformat}
// Triples, wrap in union graph, then produce quads.
Op op1 = Algebra.compile(QueryFactory.create("SELECT * { ?s
<http://example/p> ?z . ?z <http://example/q> ?o }"));
Op op2 = new OpGraph(Quad.unionGraph, op1);
Op op3 = Algebra.toQuadForm(op2);
System.out.println(op3);
Query q = OpAsQuery.asQuery(op3);
System.out.println(q);
{noformat}
What I'd like to achieve is to deprecate {{Algebra.unionDefaultGraph}} - the
rewrite behind it can't deliver on the contract if we include paths without
resorting to {{Quad.unionGraph}} for path evaluation.
> Algebra.unionDefaultGraph: OpPath not handled
> ---------------------------------------------
>
> Key: JENA-1945
> URL: https://issues.apache.org/jira/browse/JENA-1945
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ
> Affects Versions: Jena 3.16.0
> Reporter: Claus Stadler
> Priority: Major
>
>
> {code:java}
> System.out.println(
> Algebra.unionDefaultGraph(
> Algebra.compile(
> QueryFactory.create("SELECT * { ?s <urn:p> ?o }"))));
> /* Yields correct result:
> (distinct
> (graph ??_
> (bgp (triple ?s <urn:p> ?o))))
> */
> System.out.println(
> Algebra.unionDefaultGraph(
> Algebra.compile(
> QueryFactory.create("SELECT * { ?s <urn:p1>/<urn:p2>/<urn:p3> ?o }"))));
> /* Yields incorrect result because wrapping with graph ??_ (and distinct) is
> missing:
> (path ?s (seq (seq <urn:p1> <urn:p2>) <urn:p3>) ?o)
> */
> {code}
>
> It seems
> [TransformUnionQuery.java|https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/sparql/algebra/TransformUnionQuery.java#L34]
> lacks the handling of (at least) OpPath
--
This message was sent by Atlassian Jira
(v8.3.4#803005)