de.fuberlin.wiwiss.d2rq.algebra
Class JoinOptimizer

java.lang.Object
  extended by de.fuberlin.wiwiss.d2rq.algebra.JoinOptimizer

public class JoinOptimizer
extends Object

Removes unnecessary joins from a TripleRelation 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:

  1. The only join mentioning T2 is J.
  2. All columns of T2 that are selected or constrained or used in an expression occur in J's join condition.
  3. 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: Currently this only is used for TripleRelations in FindQuery but it could be used for NodeRelations in SPARQL queries too TODO: Prune unnecessary aliases after removing joins

Author:
Richard Cyganiak (richard@cyganiak.de)

Constructor Summary
JoinOptimizer(TripleRelation relation)
          Constructs a new JoinOptimizer.
 
Method Summary
 TripleRelation optimize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinOptimizer

public JoinOptimizer(TripleRelation relation)
Constructs a new JoinOptimizer.

Parameters:
relation - The TripleRelation to be optimized
Method Detail

optimize

public TripleRelation optimize()