org.d2rq.algebra
Class NodeRelationProjecter

java.lang.Object
  extended by org.d2rq.db.op.util.OpMutator
      extended by org.d2rq.algebra.NodeRelationProjecter

public class NodeRelationProjecter
extends OpMutator

Projects a NodeRelation. Projections are pushed down over LimitOp and EmptyOp, merged with other ProjectOps, done over a sub-SELECT for DistinctOps, and simply wrapped around all other kinds of DatabaseOps.

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
NodeRelationProjecter(NodeRelation original, Set<ProjectionSpec> projections)
           
 
Method Summary
 NodeRelation getNodeRelation()
           
 DatabaseOp visit(SQLOp original)
           
 DatabaseOp visit(TableOp original)
           
 boolean visitEnter(AliasOp original)
           
 boolean visitEnter(DistinctOp original)
           
 boolean visitEnter(InnerJoinOp original)
           
 boolean visitEnter(OrderOp original)
           
 boolean visitEnter(ProjectOp original)
           
 boolean visitEnter(SelectOp original)
           
 DatabaseOp visitLeave(AliasOp original, DatabaseOp child)
           
 DatabaseOp visitLeave(DistinctOp original, DatabaseOp child)
          We have a DISTINCT clause; adding or removing columns would change the result.
 DatabaseOp visitLeave(InnerJoinOp original, Collection<NamedOp> newChildren)
          TODO: Can we push parts of the projection down into the join?
 DatabaseOp visitLeave(OrderOp original, DatabaseOp child)
          TODO: Can we push the projection down over the ordering?
 DatabaseOp visitLeave(ProjectOp original, DatabaseOp child)
          Merge the projection lists.
 DatabaseOp visitLeave(SelectOp original, DatabaseOp child)
          TODO: Can we push the projection down over the selection?
 DatabaseOp visitOpTrue()
           
 
Methods inherited from class org.d2rq.db.op.util.OpMutator
getResult, visitEnter, visitEnter, visitEnter, visitLeave, visitLeave, visitLeave
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeRelationProjecter

public NodeRelationProjecter(NodeRelation original,
                             Set<ProjectionSpec> projections)
Method Detail

getNodeRelation

public NodeRelation getNodeRelation()

visitEnter

public boolean visitEnter(InnerJoinOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(InnerJoinOp original,
                             Collection<NamedOp> newChildren)
TODO: Can we push parts of the projection down into the join? E.g., can we eliminate one of the tables in the join, or remove a column from a sub-select?

Overrides:
visitLeave in class OpMutator

visitEnter

public boolean visitEnter(SelectOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(SelectOp original,
                             DatabaseOp child)
TODO: Can we push the projection down over the selection? All the columns needed for the selection must be present in the projection. This can be beneficial if the projection can be pushed even further down, e.g., over a join.

Overrides:
visitLeave in class OpMutator

visitEnter

public boolean visitEnter(ProjectOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(ProjectOp original,
                             DatabaseOp child)
Merge the projection lists.

Overrides:
visitLeave in class OpMutator

visitEnter

public boolean visitEnter(AliasOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(AliasOp original,
                             DatabaseOp child)
Overrides:
visitLeave in class OpMutator

visitEnter

public boolean visitEnter(OrderOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(OrderOp original,
                             DatabaseOp child)
TODO: Can we push the projection down over the ordering? All the columns needed for the order spec must be present in the projection. This can be beneficial if the projection can be pushed even further down, e.g., over a join.

Overrides:
visitLeave in class OpMutator

visitEnter

public boolean visitEnter(DistinctOp original)
Overrides:
visitEnter in class OpMutator

visitLeave

public DatabaseOp visitLeave(DistinctOp original,
                             DatabaseOp child)
We have a DISTINCT clause; adding or removing columns would change the result. So we have to wrap the entire thing into a sub-SELECT, apply DISTINCT on the sub-SELECT, and rename everything in the node makers to use the new table name.

Overrides:
visitLeave in class OpMutator

visit

public DatabaseOp visit(TableOp original)
Overrides:
visit in class OpMutator

visit

public DatabaseOp visit(SQLOp original)
Overrides:
visit in class OpMutator

visitOpTrue

public DatabaseOp visitOpTrue()
Overrides:
visitOpTrue in class OpMutator