Package org.aksw.qa.commons.sparql
Class SPARQL
java.lang.Object
org.aksw.qa.commons.sparql.SPARQL
- Direct Known Subclasses:
ThreadedSPARQL
Executes sparql queries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.Loggerorg.aksw.jena_sparql_api.core.QueryExecutionFactoryprivate long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidcloseExecFactory(org.aksw.jena_sparql_api.core.QueryExecutionFactory qef)static BooleanexecuteAsk(String query, String endpoint)Executes an ask query for the given endpoint and query.static ResultsexecuteSelect(String query, String endpoint)Executes a select query for the given endpoint and query.extractAnswerStrings(Set<org.apache.jena.rdf.model.RDFNode> answers)For use withsparql(String)Extracts answer strings.longstatic booleanisEndpointAlive(String endpoint)Checks if the given endpoint is alive.static booleanisValidSparqlQuery(String sparql)Tries to parse query with apache.jena .voidsetCacheTimeToLive(long timeToLive)Set<org.apache.jena.rdf.model.RDFNode>Fire a sparql query against endpoint defined in constructor.
-
Field Details
-
log
private org.slf4j.Logger log -
qef
public org.aksw.jena_sparql_api.core.QueryExecutionFactory qef -
timeToLive
private long timeToLive
-
-
Constructor Details
-
SPARQL
public SPARQL()SPARQLEndpoints.DBPEDIA_ORGas endpoint used. -
SPARQL
- Parameters:
endpoint- - A sparql endpoint, e.g.SPARQLEndpoints.DBPEDIA_ORG
-
-
Method Details
-
sparql
Fire a sparql query against endpoint defined in constructor.NOTE: This will block. To set a maximum execution time, use
ThreadedSPARQLFor string representation of answers, see
extractAnswerStrings(Set)- Parameters:
query- - a sparql query- Returns:
-
extractAnswerStrings
For use withsparql(String)Extracts answer strings. Can be directly set as golden answers in an IQuestion.- Parameters:
answers-- Returns:
-
executeSelect
Executes a select query for the given endpoint and query. Returns the answer as anResultsobject.- Parameters:
query-endpoint-- Returns:
-
executeAsk
Executes an ask query for the given endpoint and query.- Parameters:
query-endpoint-- Returns:
-
getCacheTimeToLive
public long getCacheTimeToLive()- Returns:
- - The time to live of frontendCache
-
setCacheTimeToLive
public void setCacheTimeToLive(long timeToLive) -
isValidSparqlQuery
Tries to parse query with apache.jena . If fails, returns false.- Parameters:
sparql-- Returns:
-
isEndpointAlive
Checks if the given endpoint is alive. If fails, returns false.- Parameters:
endpoint-- Returns:
-
closeExecFactory
private static void closeExecFactory(org.aksw.jena_sparql_api.core.QueryExecutionFactory qef)
-