de.fuberlin.wiwiss.d2rq.algebra
Class JoinOptimizer
java.lang.Object
de.fuberlin.wiwiss.d2rq.algebra.JoinOptimizer
public class JoinOptimizer
- extends Object
Removes unnecessary joins from an RDFRelation
in cases
where this is possible without affecting the result. This is an
optimization.
A join J from table T1 to table T2 with join condition
T1.c_1 = T2.c_1 && T1.c_2 = T2.c_2 && ...
can be removed if these conditions hold:
- The only join mentioning T2 is J.
- All columns of T2 that are selected or constrained or used in
an expression occur in J's join condition.
- All values of T1.c_n are guaranteed to occur
in T2.c_n, that is, there is a foreign key constraint
on T1.c_n.
In this case, J can be dropped, and all mentions of T2.c_n
can be replaced with T1.c_n.
TODO: Note: The third condition is currently not enforced.
This is not a problem in most situations, because d2rq:join is typically
used along an FK constraint. At this point in the code, we don't know the
direction of the FK though. The way 1:n and n:m joins are typically used,
condition 2 will exclude most cases where the FK is on T2.c_n.
However, it will not catch cases that result from a d2rq:join on a
d2rq:ClassMap along an 1:1 relation. This should be considered a bug.
TODO: Prune unnecessary aliases after removing joins
- Version:
- $Id: JoinOptimizer.java,v 1.11 2006/09/28 12:17:44 cyganiak Exp $
- Author:
- Richard Cyganiak (richard@cyganiak.de)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JoinOptimizer
public JoinOptimizer(RDFRelation base)
- Constructs a new JoinOptimizer.
- Parameters:
base
- The RDFRelation to be optimized
optimize
public RDFRelation optimize()