Class GraphQuerySQLProvider

  extended by org.nsdl.mptstore.query.provider.GraphQuerySQLProvider
All Implemented Interfaces:
SQLBuilder, SQLProvider

public class GraphQuerySQLProvider
extends java.lang.Object
implements SQLBuilder, SQLProvider

Translates a GraphQuery into a series of SQL statements.

Produces ANSI SQL-92 queries by converting each GraphPattern leaf of the query tree into a series of JOINs. Each join condition is formed by matching variables between TriplePatterns in the appripriate GraphPatterns.



Constructor Summary
GraphQuerySQLProvider(TableManager tableManager, GraphQuery graphQuery)
          Create an instance.
Method Summary
 java.util.List<java.lang.String> getSQL()
          Returns a query in ANSI SQL
 java.util.List<java.lang.String> getTargets()
          Get the names of the values that are being selected.
 void orderBy(java.lang.String target, boolean desc)
          Force an order on the results.
 void setTargets(java.util.List<java.lang.String> targetList)
          Choose the variables that define result tuples
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public GraphQuerySQLProvider(TableManager tableManager,
                             GraphQuery graphQuery)
Create an instance.

tableManager - the table manager to use for looking up table names.
graphQuery - the graph query.
Method Detail


public void setTargets(java.util.List<java.lang.String> targetList)
Choose the variables that define result tuples

The given list of variables are used for determining which bound values are included in result tuples, and in what order. If a variable is specified as a target, it must be present somewhere in the query. Any unmatched target will result in error

Specified by:
setTargets in interface SQLBuilder
targetList - the list of query variables.
See Also:


public void orderBy(java.lang.String target,
                    boolean desc)
Force an order on the results.

Given the name of a target variable, results will be ordered by its bound value. Results may be specified to return in ascending or descending order.

target - Name of the target variable whose value will be the sort key.
desc - True if results are to be in desceiding order, false otherwise.


public java.util.List<java.lang.String> getSQL()
                                        throws QueryException
Returns a query in ANSI SQL

Translates the GraphQuery defined in the constructor, along with any specified orderings , into a set of SQL statements. The union of all SQL statement results, executed in order, will represent the entire result set.

Specified by:
getSQL in interface SQLProvider
list of SQL statements
QueryException - if there is some error translating the query to SQL.


public java.util.List<java.lang.String> getTargets()
Get the names of the values that are being selected. These should be in the same order specified in the original RDF query, and should match the order of the associated values in the SQL.

Specified by:
getTargets in interface SQLProvider
the target names.