com.bigdata.rdf.sail.webapp
Class BigdataRDFContext.AbstractQueryTask

java.lang.Object
  extended by com.bigdata.rdf.sail.webapp.BigdataRDFContext.AbstractQueryTask
All Implemented Interfaces:
Callable<Void>
Enclosing class:
BigdataRDFContext

public abstract class BigdataRDFContext.AbstractQueryTask
extends Object
implements Callable<Void>

Abstract base class for running queries handles the timing, pipe, reporting, obtains the connection, and provides the finally {} semantics for each type of query task.

Author:
Bryan Thompson

Field Summary
protected  ASTContainer astContainer
          The ASTContainer provides access to the original SPARQL query, the query model, the query plan, etc.
protected  String baseURI
          The baseURI is set from the effective request URI.
protected  Charset charset
          The character encoding to use with the negotiated mimeType -or- null (it will be null for a binary encoding).
protected  String fileExt
          The file extension (without the leading ".") to use with the negotiated mimeType -or- null if this is a SPARQL UPDATE request
protected  String mimeType
          The negotiated MIME type to be used for the query response (this does not include the charset encoding) -or- null if this is a SPARQL UPDATE request.
protected  OutputStream os
          Where to write the response.
protected  Long queryId
          The queryId as assigned by the SPARQL end point (rather than the QueryEngine).
protected  UUID queryId2
          The queryId used by the QueryEngine.
protected  QueryType queryType
          A symbolic constant indicating the type of query.
protected  javax.servlet.http.HttpServletRequest req
          The request.
protected  AbstractOperation sailQueryOrUpdate
          The parsed query.
 long timestamp
          The timestamp of the view for that namespace against which the query will be run.
protected  boolean update
          true iff this is a SPARQL UPDATE request.
 
Constructor Summary
protected BigdataRDFContext.AbstractQueryTask(String namespace, long timestamp, String baseURI, ASTContainer astContainer, javax.servlet.http.HttpServletRequest req, OutputStream os)
           
protected BigdataRDFContext.AbstractQueryTask(String namespace, long timestamp, String baseURI, ASTContainer astContainer, QueryType queryType, String mimeType, Charset charset, String fileExt, javax.servlet.http.HttpServletRequest req, OutputStream os)
           
 
Method Summary
 Void call()
           
protected abstract  void doQuery(BigdataSailRepositoryConnection cxn, OutputStream os)
          Execute the query.
protected  void overrideDataset(AbstractOperation queryOrUpdate)
          If the HttpServletRequest included one or more of then the Dataset for the query is replaced by the Dataset constructed from those protocol parameters (the parameters which are recognized are different for query and SPARQL update).
protected  UUID setQueryId(ASTContainer astContainer)
          Determines the UUID which will be associated with the IRunningQuery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timestamp

public final long timestamp
The timestamp of the view for that namespace against which the query will be run.


baseURI

protected final String baseURI
The baseURI is set from the effective request URI.


astContainer

protected final ASTContainer astContainer
The ASTContainer provides access to the original SPARQL query, the query model, the query plan, etc.


update

protected final boolean update
true iff this is a SPARQL UPDATE request.


queryType

protected final QueryType queryType
A symbolic constant indicating the type of query.


mimeType

protected final String mimeType
The negotiated MIME type to be used for the query response (this does not include the charset encoding) -or- null if this is a SPARQL UPDATE request.


charset

protected final Charset charset
The character encoding to use with the negotiated mimeType -or- null (it will be null for a binary encoding).


fileExt

protected final String fileExt
The file extension (without the leading ".") to use with the negotiated mimeType -or- null if this is a SPARQL UPDATE request


req

protected final javax.servlet.http.HttpServletRequest req
The request.


os

protected final OutputStream os
Where to write the response.


queryId

protected final Long queryId
The queryId as assigned by the SPARQL end point (rather than the QueryEngine).


queryId2

protected volatile UUID queryId2
The queryId used by the QueryEngine. If the application has not specified this using QueryHints.QUERYID then this is assigned and set on the query using QueryHints.QUERYID. This decision can not be made until we parse the query so the behavior is handled by the subclasses.


sailQueryOrUpdate

protected AbstractOperation sailQueryOrUpdate
The parsed query. It will be one of the BigdataSailQuery implementations or BigdataSailUpdate. They all extend AbstractOperation.

Note: This field is made visible by the volatile write on queryId2.

Constructor Detail

BigdataRDFContext.AbstractQueryTask

protected BigdataRDFContext.AbstractQueryTask(String namespace,
                                              long timestamp,
                                              String baseURI,
                                              ASTContainer astContainer,
                                              QueryType queryType,
                                              String mimeType,
                                              Charset charset,
                                              String fileExt,
                                              javax.servlet.http.HttpServletRequest req,
                                              OutputStream os)
Parameters:
namespace - The namespace against which the query will be run.
timestamp - The timestamp of the view for that namespace against which the query will be run.
baseURI - The base URI.
astContainer - The container with all the information about the submitted query, including the original SPARQL query, the parse tree, etc.
queryType - The QueryType.
mimeType - The MIME type to be used for the response. The caller must verify that the MIME Type is appropriate for the query type.
charset - The character encoding to use with the negotiated MIME type (this is null for binary encodings).
fileExt - The file extension (without the leading ".") to use with that MIME Type.
req - The request.
os - Where to write the data for the query result.

BigdataRDFContext.AbstractQueryTask

protected BigdataRDFContext.AbstractQueryTask(String namespace,
                                              long timestamp,
                                              String baseURI,
                                              ASTContainer astContainer,
                                              javax.servlet.http.HttpServletRequest req,
                                              OutputStream os)
Parameters:
namespace - The namespace against which the query will be run.
timestamp - The timestamp of the view for that namespace against which the query will be run.
baseURI - The base URI.
astContainer - The container with all the information about the submitted query, including the original SPARQL query, the parse tree, etc.
req - The request.
os - Where to write the data for the query result.
Method Detail

overrideDataset

protected void overrideDataset(AbstractOperation queryOrUpdate)
If the HttpServletRequest included one or more of then the Dataset for the query is replaced by the Dataset constructed from those protocol parameters (the parameters which are recognized are different for query and SPARQL update).

Parameters:
queryOrUpdate - The query.

setQueryId

protected UUID setQueryId(ASTContainer astContainer)
Determines the UUID which will be associated with the IRunningQuery. If QueryHints.QUERYID has already been used by the application to specify the UUID then that UUID is noted. Otherwise, a random UUID is generated and assigned to the query by binding it on the query hints.

Note: The ability to provide metadata from the ASTContainer in the StatusServlet or the "EXPLAIN" page depends on the ability to cross walk the queryIds as established by this method.

Parameters:
query - The query.
Returns:
The UUID which will be associated with the IRunningQuery.

doQuery

protected abstract void doQuery(BigdataSailRepositoryConnection cxn,
                                OutputStream os)
                         throws Exception
Execute the query.

Parameters:
cxn - The connection.
os - Where the write the query results.
Throws:
Exception

call

public final Void call()
                throws Exception
Specified by:
call in interface Callable<Void>
Throws:
Exception


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.