de.fuberlin.wiwiss.d2rq.rdql
Class PatternQueryCombiner

java.lang.Object
  extended byde.fuberlin.wiwiss.d2rq.rdql.PatternQueryCombiner

class PatternQueryCombiner
extends java.lang.Object

Handles a triple pattern query on a D2RQ mapped database. (Current)Assumption: all PropertyBridges refer to same database. Contract: after Constructor, first call setup() then call resultTriplesIterator().

This class does not need to know anything about D2RQPatternStage, except it's VariableBindings semantics.

It seems that some of the information computed here could be reused in successive calls from D2RQPatternStage2. On the other hand, lots of preprocessing is useless, if there are (Bound) variables for predicates.

Author:
jgarbers
See Also:
QueryCombiner

Nested Class Summary
private  class PatternQueryCombiner.PQCResultIterator
          Iterator for PatternQueryCombiner results.
 
Field Summary
(package private)  VariableBindings bindings
           
protected  java.util.ArrayList[] bridges
          holds for each triple its 'a priory' appliable bridges
protected  int[] bridgesCounts
          holds for each triple its number of bridges or tripleQueries
protected  java.util.Collection constraints
           
protected  Database database
           
protected  GraphD2RQ graph
           
private  boolean possible
          if false then contradiction, no SQL query necessary.
protected  int tripleCount
           
protected  TripleQuery[][] tripleQueries
          holds for each triple its disjunctive SQL-TripleQuery Objects
protected  com.hp.hpl.jena.graph.Triple[] triples
           
 
Constructor Summary
PatternQueryCombiner(GraphD2RQ graph, VariableBindings bindings, java.util.Collection constraints, com.hp.hpl.jena.graph.Triple[] triples)
           
 
Method Summary
private  SQLStatementMaker getSQL(TripleQuery[] conjunction)
           
(package private)  void makePropertyBridges()
          Creates copies of the property bridges that could fit the triples.
(package private)  void makeStores()
          allocates arrays
(package private)  void makeTripleQueries()
          Creates a TripleQuery for each PropertyBridge.
(package private)  void reducePropertyBridges()
           
 com.hp.hpl.jena.util.iterator.ClosableIterator resultTriplesIterator()
           
(package private)  void setup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

possible

private boolean possible
if false then contradiction, no SQL query necessary.


database

protected Database database

graph

protected GraphD2RQ graph

triples

protected com.hp.hpl.jena.graph.Triple[] triples

tripleCount

protected int tripleCount

constraints

protected java.util.Collection constraints

bindings

VariableBindings bindings

bridges

protected java.util.ArrayList[] bridges
holds for each triple its 'a priory' appliable bridges


bridgesCounts

protected int[] bridgesCounts
holds for each triple its number of bridges or tripleQueries


tripleQueries

protected TripleQuery[][] tripleQueries
holds for each triple its disjunctive SQL-TripleQuery Objects

Constructor Detail

PatternQueryCombiner

public PatternQueryCombiner(GraphD2RQ graph,
                            VariableBindings bindings,
                            java.util.Collection constraints,
                            com.hp.hpl.jena.graph.Triple[] triples)
Method Detail

setup

void setup()

makeStores

void makeStores()
allocates arrays


makePropertyBridges

void makePropertyBridges()
Creates copies of the property bridges that could fit the triples. Two triples that are combined with AND generally have nothing in common, so we create individual instances of the bridges and systematically rename their tables. We prefix each Table with "T_ where is the index of the triple in the overall query.

See Also:
TablePrefixer

makeTripleQueries

void makeTripleQueries()
Creates a TripleQuery for each PropertyBridge. As a side effect we also set bridgesCounts.


reducePropertyBridges

void reducePropertyBridges()

getSQL

private SQLStatementMaker getSQL(TripleQuery[] conjunction)

resultTriplesIterator

public com.hp.hpl.jena.util.iterator.ClosableIterator resultTriplesIterator()