Package org.aksw.qa.commons.sparql
Class ThreadedSPARQL
java.lang.Object
org.aksw.qa.commons.sparql.SPARQL
org.aksw.qa.commons.sparql.ThreadedSPARQL
Fire a sparql query against an endpoint
SPARQL.sparql(String) will block, if server doesn't respond. Here, you can set a maximum time limit.
This is achieved by wrapping underlying SPARQL in a Thread, which then has a maximum execution time.
- Author:
- jhuth
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescription#ENDPOINT_DBPEDIA_ORGas endpoint used.ThreadedSPARQL(int timeoutInSeconds, String endpoint)ThreadedSPARQL(String endpoint)Default timeout : 10 seconds -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Call this to close the underlying thread pool.intvoidsetTimeoutInSeconds(int timeoutInSeconds)Set<org.apache.jena.rdf.model.RDFNode>Fire a sparql query against endpoint defined in constructor.Methods inherited from class org.aksw.qa.commons.sparql.SPARQL
executeAsk, executeSelect, extractAnswerStrings, getCacheTimeToLive, isEndpointAlive, isValidSparqlQuery, setCacheTimeToLive
-
Field Details
-
timeoutInSeconds
private int timeoutInSeconds -
log
private final org.slf4j.Logger log -
executor
-
-
Constructor Details
-
ThreadedSPARQL
public ThreadedSPARQL()#ENDPOINT_DBPEDIA_ORGas endpoint used.Default timeout : 10 seconds
-
ThreadedSPARQL
Default timeout : 10 seconds -
ThreadedSPARQL
- Parameters:
timeoutInSeconds- - set a maximum time limit for the execution of one query. Only set if >0 otherwise ignored (default=10s)endpoint- - A sparql endpoint, e.g.SPARQLEndpoints.DBPEDIA_ORG
-
-
Method Details
-
sparql
Fire a sparql query against endpoint defined in constructor.This will break operation after
timeoutInSecondshas been reached. in this case, null is returned.For string representation of answers, see
SPARQL.extractAnswerStrings(Set) -
getTimeoutInSeconds
public int getTimeoutInSeconds()- Returns:
- - the time after a query times out.
-
setTimeoutInSeconds
public void setTimeoutInSeconds(int timeoutInSeconds)- Parameters:
timeoutInSeconds- - the time after a query times out.
-
destroy
public void destroy()Call this to close the underlying thread pool.
-