org.openanzo.server.repository.query
Class ServerSolutionGenerator

java.lang.Object
  extended by org.openanzo.server.repository.query.ServerSolutionGenerator
All Implemented Interfaces:
SolutionGenerator

public class ServerSolutionGenerator
extends java.lang.Object
implements SolutionGenerator

ServerSolutionGenerator implements the core of the Anzo backend for glitter queries; it translates SPARQL queries into SQL queries against the Anzo temporal RDF store schema.


Constructor Summary
ServerSolutionGenerator(RepositoryConnection connection, java.lang.Long transactionTime, IndexerFactoryBase indexQueryApi, boolean includeInferredStatements)
          Create a new ServerSolutionGenerator
 
Method Summary
 boolean canBindGraphVariables()
          Informative method.
 boolean canHandleSimultaneousRequests()
          Informative method.
 void cleanup()
          Called after all calls to generateSolutions.
 SolutionSet generateSolutions(TreeNode node, IRIReference namedGraph, Variable namedGraphVariable, SolutionSet requiredBindings)
           
 RepositoryConnection getConnection()
           
 QueryExecutionPlan getQueryExecutionPlan()
           
 QueryExecutionServices getQueryExecutionServices()
           
 QueryInformation getQueryInformation()
           
 RDFDataset<?> getRDFDataset()
           
 long getUserId()
           
 void initialize()
          Called before any calls to generateSolutions but after all calls to set*.
 void setIncludeInferredTriples(boolean includeInferredTriples)
           
 void setOntology(java.net.URI ontology)
           
 void setQueryExecutionPlan(QueryExecutionPlan plan)
           
 void setQueryExecutionServices(QueryExecutionServices services)
           
 void setQueryInformation(QueryInformation queryInformation)
           
 void setRDFDataset(RDFDataset<?> dataset)
           
 boolean sortedSolutions()
           
 boolean usesRequiredBindings()
          Informative method.
 boolean willHandleFilters(java.util.Set<Expression> filters)
          Many backends do not implement filters, in which case Glitter will filter results even if the solution generator handles a node which subsumes filters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerSolutionGenerator

public ServerSolutionGenerator(RepositoryConnection connection,
                               java.lang.Long transactionTime,
                               IndexerFactoryBase indexQueryApi,
                               boolean includeInferredStatements)
Create a new ServerSolutionGenerator

Parameters:
connection - connection to the database
transactionTime - timestamp of last transaction to include in queries
indexQueryApi - reference to the indexer api, in order to do textMatch special predicate searches
includeInferredStatements - include inferred statements in query results
Method Detail

initialize

public void initialize()
                throws GlitterException
Description copied from interface: SolutionGenerator
Called before any calls to generateSolutions but after all calls to set*.

Specified by:
initialize in interface SolutionGenerator
Throws:
GlitterException

cleanup

public void cleanup()
             throws GlitterException
Description copied from interface: SolutionGenerator
Called after all calls to generateSolutions.

Specified by:
cleanup in interface SolutionGenerator
Throws:
GlitterException

generateSolutions

public SolutionSet generateSolutions(TreeNode node,
                                     IRIReference namedGraph,
                                     Variable namedGraphVariable,
                                     SolutionSet requiredBindings)
                              throws CannotGenerateSolutionsException
Specified by:
generateSolutions in interface SolutionGenerator
Parameters:
node - The node in the tree for which bindings are desired.
namedGraph - If not null, the solutions should be generated by matching against this graph from the named graph part of the RDF dataSet. Otherwise, the solutions should be generated from the default graph. (i.e., if not null, treat this graph as the default graph)
namedGraphVariable - If not null and this SolutionGenerator returns true for canBindGraphVariables(), then this is the variable that should be bound to the named graph IRI from which solutions are found.
requiredBindings - Known bindings at this point in the AST. Every returned solution should be a superset of one solution from the required bindings. (That is, unbound variables can be bound, but all bound variables must remain bound to the same value.) Note that Glitter enforces this constraint when combining pattern solutions. In general, if generateSolutions returns a value (null or otherwise), then the SolutionGenerator will not be called again for any descendants of node. If an exception is thrown, then generateSolution may be called for descendant (simpler) nodes.
Returns:
A list of bindings (for variables and blank nodes) that satisfy the given tree node, or null if this pattern doesn't match.
Throws:
CannotGenerateSolutionsException - if the SolutionGenerator does not wish to handle this tree node.

setQueryExecutionPlan

public void setQueryExecutionPlan(QueryExecutionPlan plan)
Specified by:
setQueryExecutionPlan in interface SolutionGenerator
Parameters:
plan - The execution plan in use.

setQueryInformation

public void setQueryInformation(QueryInformation queryInformation)
Specified by:
setQueryInformation in interface SolutionGenerator
Parameters:
queryInformation - Information on the parsed and prepared query.

setQueryExecutionServices

public void setQueryExecutionServices(QueryExecutionServices services)
Specified by:
setQueryExecutionServices in interface SolutionGenerator

setRDFDataset

public void setRDFDataset(RDFDataset<?> dataset)
Specified by:
setRDFDataset in interface SolutionGenerator
Parameters:
dataset - The RDFDataset against which the query is being executed.

sortedSolutions

public boolean sortedSolutions()
Specified by:
sortedSolutions in interface SolutionGenerator
Returns:
whether or not the generator sorts returned solutions as per any ORDER BY information

canHandleSimultaneousRequests

public boolean canHandleSimultaneousRequests()
Description copied from interface: SolutionGenerator
Informative method.

Specified by:
canHandleSimultaneousRequests in interface SolutionGenerator
Returns:
Whether or not this backend can handle multiple requests in parallel.

canBindGraphVariables

public boolean canBindGraphVariables()
Description copied from interface: SolutionGenerator
Informative method.

Specified by:
canBindGraphVariables in interface SolutionGenerator
Returns:
Whether or not this backend can range over a graph variable and bind the variable to the appropriate graphs from the named graph part of the RDFDataset

usesRequiredBindings

public boolean usesRequiredBindings()
Description copied from interface: SolutionGenerator
Informative method.

Specified by:
usesRequiredBindings in interface SolutionGenerator
Returns:
Whether or not this backend makes use of known constraints passed in when generating solutions.

willHandleFilters

public boolean willHandleFilters(java.util.Set<Expression> filters)
Description copied from interface: SolutionGenerator
Many backends do not implement filters, in which case Glitter will filter results even if the solution generator handles a node which subsumes filters. (Other than an OPTIONAL -- a solution generator should only handle an OPTIONAL that includes a filter if it can handle the filter.)

Specified by:
willHandleFilters in interface SolutionGenerator
Returns:
true if the solution generator will take care of these filters on any nodes that it sees, false if Glitter should handle the filters.

getQueryExecutionPlan

public QueryExecutionPlan getQueryExecutionPlan()
Specified by:
getQueryExecutionPlan in interface SolutionGenerator
Returns:
Accessor to the execution plan

getQueryExecutionServices

public QueryExecutionServices getQueryExecutionServices()
Specified by:
getQueryExecutionServices in interface SolutionGenerator
Returns:
QueryExecutionServices for this SolutionGenerator

getQueryInformation

public QueryInformation getQueryInformation()
Specified by:
getQueryInformation in interface SolutionGenerator
Returns:
Accessor to the parsed query

getRDFDataset

public RDFDataset<?> getRDFDataset()
Specified by:
getRDFDataset in interface SolutionGenerator
Returns:
Accessor to the dataset

getConnection

public RepositoryConnection getConnection()
Returns:
the connection

getUserId

public long getUserId()
Returns:
the userId

setIncludeInferredTriples

public void setIncludeInferredTriples(boolean includeInferredTriples)
Specified by:
setIncludeInferredTriples in interface SolutionGenerator
Parameters:
includeInferredTriples - Whether or not inferred triples should contribute to bindings.

setOntology

public void setOntology(java.net.URI ontology)
Specified by:
setOntology in interface SolutionGenerator
Parameters:
ontology - The ontology in effect for inferred triples.


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.