Package org.eclipse.rdf4j.federated
Class QueryManager
- java.lang.Object
-
- org.eclipse.rdf4j.federated.QueryManager
-
public class QueryManager extends Object
QueryManager to manage queries. a) Management of running queries (abort, finish) b) Factory to create queries- Author:
- Andreas Schwarte
-
-
Constructor Summary
Constructors Constructor Description QueryManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortQuery(QueryInfo queryInfo)
void
addPrefixDeclaration(String prefix, String namespace)
Register a prefix declaration to be used during query evaluation.protected static Set<String>
findQueryPrefixes(String queryString)
Find all prefixes declared in the queryvoid
finishQuery(QueryInfo queryInfo)
BigInteger
getNextQueryId()
Computes the (incremental) next query identifier.int
getNumberOfRunningQueries()
protected String
getPrefixDeclarations()
Get the prefix declarations that have to be prepended to the query.protected String
getPrefixDeclarationsCheck(String queryString)
Get the prefix declarations that have to be added while considering prefixes that are already declared in the query.String
getQueryPlan(String queryString)
Retrieve the query plan for the given query string.Set<QueryInfo>
getRunningQueries()
void
init(FedXRepository repo, FederationContext federationContext)
boolean
isRunning(QueryInfo queryInfo)
BooleanQuery
prepareBooleanQuery(String queryString)
Prepare a boolean query which uses the underlying federation to evaluate the query.GraphQuery
prepareGraphQuery(String queryString)
Prepare a tuple query which uses the underlying federation to evaluate the query.Query
prepareQuery(String queryString)
Prepare aQuery
which uses the underlying federation to evaluate the SPARQL query.TupleQuery
prepareTupleQuery(String queryString)
Prepare a tuple query which uses the underlying federation to evaluate the query.void
registerQuery(QueryInfo queryInfo)
Add the query to the set of running queries, queries are identified via a unique idvoid
shutdown()
-
-
-
Method Detail
-
init
public void init(FedXRepository repo, FederationContext federationContext)
-
shutdown
public void shutdown()
-
registerQuery
public void registerQuery(QueryInfo queryInfo)
Add the query to the set of running queries, queries are identified via a unique id- Parameters:
queryInfo
-
-
getNumberOfRunningQueries
public int getNumberOfRunningQueries()
-
abortQuery
public void abortQuery(QueryInfo queryInfo)
-
finishQuery
public void finishQuery(QueryInfo queryInfo)
-
isRunning
public boolean isRunning(QueryInfo queryInfo)
-
addPrefixDeclaration
public void addPrefixDeclaration(String prefix, String namespace)
Register a prefix declaration to be used during query evaluation. If a known prefix is used in a query, it is substituted in the parsing step. If namespace is null, the corresponding entry is removed.- Parameters:
prefix
- a common prefix, e.g. rdfnamespace
- the corresponding namespace, e.g. "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-
prepareTupleQuery
public TupleQuery prepareTupleQuery(String queryString) throws MalformedQueryException
Prepare a tuple query which uses the underlying federation to evaluate the query.The queryString is modified to use the declared PREFIX declarations, see
FedXConfig.getPrefixDeclarations()
for details.- Parameters:
queryString
-- Returns:
- the prepared tuple query
- Throws:
MalformedQueryException
-
prepareGraphQuery
public GraphQuery prepareGraphQuery(String queryString) throws MalformedQueryException
Prepare a tuple query which uses the underlying federation to evaluate the query.The queryString is modified to use the declared PREFIX declarations, see
FedXConfig.getPrefixDeclarations()
for details.- Parameters:
queryString
-- Returns:
- the prepared graph query
- Throws:
MalformedQueryException
-
prepareBooleanQuery
public BooleanQuery prepareBooleanQuery(String queryString) throws MalformedQueryException
Prepare a boolean query which uses the underlying federation to evaluate the query.The queryString is modified to use the declared PREFIX declarations, see
FedXConfig.getPrefixDeclarations()
for details.- Parameters:
queryString
-- Returns:
- the prepared
BooleanQuery
- Throws:
MalformedQueryException
-
prepareQuery
public Query prepareQuery(String queryString) throws MalformedQueryException
Prepare aQuery
which uses the underlying federation to evaluate the SPARQL query.The queryString is modified to use the declared PREFIX declarations, see
FedXConfig.getPrefixDeclarations()
for details.- Parameters:
queryString
-- Returns:
- the prepared
Query
- Throws:
MalformedQueryException
-
getQueryPlan
public String getQueryPlan(String queryString) throws MalformedQueryException, FedXException
Retrieve the query plan for the given query string.- Parameters:
queryString
-- Returns:
- the query plan
- Throws:
MalformedQueryException
FedXException
-
getNextQueryId
public BigInteger getNextQueryId()
Computes the (incremental) next query identifier. Implementation is thread safe and synchronized.- Returns:
- the next query identifier
-
getPrefixDeclarations
protected String getPrefixDeclarations()
Get the prefix declarations that have to be prepended to the query.- Returns:
- the prefix declarations
-
getPrefixDeclarationsCheck
protected String getPrefixDeclarationsCheck(String queryString)
Get the prefix declarations that have to be added while considering prefixes that are already declared in the query. The issue here is that duplicate declaration causes exceptions in RDF4J.- Parameters:
queryString
-- Returns:
- the prefix declarations
-
-