org.openanzo.glitter.query.rewriter
Class ConjunctiveRewriter
java.lang.Object
org.openanzo.glitter.query.rewriter.ConjunctiveRewriter
- All Implemented Interfaces:
- TreeRewriter
public class ConjunctiveRewriter
- extends java.lang.Object
- implements TreeRewriter
The ConjunctiveRewriter takes advantage of the following equalities:
{ t1 t2 { t3 } } = t1 t2 t3
That is, triples within a single BGP are conjoined, as are GraphPatterns
within a group. By flattening out nested groups and then merging multiple
BGPs within a group, we take a great deal of complexity out of the AST and
enable other query-plan optimizations.
This also conjoins multiple filtered basic graph patterns.
(Note that on the surface {t1 {t2} } is not identical to {t1 t2} because
the two triples have different blank node scopes. At this point (the AST
rewriting point), distinct blank nodes for identical labels in different
scopes have already be created, so we can lose that difference.)
(Note also that this equivalence might not hold for entaiments other than
simple entailment, and as such a backend that implements other entailments
should be wary in its use of the ConjunctiveRewriter.)
ConjunctiveRewriter only operates on Group nodes, and only manipulates
Group, BGP, and Filter nodes.
TODO @@ ConjunctiveRewriter also needs to ensure that every Group has a
BGP.
TODO @@ This could be improved to flatten single element groups regardless
of filters in children { { ?s ?p ?o. FILTER (...) } }.
- Author:
- Lee
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConjunctiveRewriter
public ConjunctiveRewriter()
rewriteTreeNode
public TreeNode rewriteTreeNode(TreeNode node)
- Description copied from interface:
TreeRewriter
- Rewrites the given node from a SPARQL abstract syntax tree.
- Specified by:
rewriteTreeNode in interface TreeRewriter
- Parameters:
node - the node in question
- Returns:
- A tree node to replace the passed in tree node. Returning
node leaves this spot in the AST unchanged. Returning null
removes this node from the tree. (Note that it is possible that removing the
node will leave the tree in an invalid state. Behavior in this case is undefined.)
Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.