Konclude via SPARQL

Konclude can be used as a SPARQL server that processes SPARQL commands and answers SPARQL queries sent via HTTP POST. In this case Konclude has to be started with the 'sparqlserver' command. The listening port can optionally be specified by the parameter '-p', otherwise the default port 8080 is used.

 > Konclude sparqlserver -p 8080

As an alternative, SPARQL commands and queries can also be processed from files by using the 'sparqlfile' command. You can list several SPARQL commands and queries in files (and also in HTTP POST requests), which are then subsequently processed by Konclude. The default graph can also be loaded via the parameter '-i FILEPATH', i.e., the command

 > sparqlfile -i Tests/roberts-family-full-D.owl.xml
            -s Tests/roberts-family-full-sparql-existential-variables-query-test.sparql

loads the ontology 'Tests/roberts-family-full-D.owl.xml' as the default graph and executes the SPARQL query in the file 'Tests/roberts-family-full-sparql-existential-variables-query-test.sparql'. Since no output file is given, Konclude will only count the number of answers.

SPARQL Commands

Konclude supports a few SPARQL Update commands (partially), such as CREATE, DROP, LOAD, INSERT, DELETE. Note that there is no efficient support for using INSERT and DELETE with large amounts of triples. You may want to consider using the LOAD command instead.

SPARQL Queries

Konclude supports SELECT and ASK queries, but natively only for ABox related basic graph patterns. With the included Redland RDF Libraries Konclude is also able to process more complex queries by using Redland Rasqal, but the performance can be non-optimal. Also note that variables are not supported in abitrary positions. In fact, variables for classes (properties) can only be used in simple SubClassOf (SubPropertyOf) and EquivalentClasses (EquivalentProperties) axioms. You can futher use these class and property variables to restrict instance retrieval/conjunctive queries, but do not expect a particularly great performance. For example, Konclude evaluates (more or less) the conjunctive query for each sub-property of 'ub:degreeFrom' (from LUBM) separately for the following query:

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ub: <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
?X rdf:type ub:GraduateStudent .
?X ub:takesCourse <http://www.Department0.University0.edu/GraduateCourse0> .
?X ?P ?Y .
?P rdfs:subPropertyOf ub:degreeFrom .

The triple patterns in SPARQL queries are mapped to OWL expressions (if possible), which, for example, can be used to query for sub-/super-classes of complex concepts or to retrieve instances of such concepts as shown with the following query:

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX ub: <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
?X rdf:type _:c1 . _:c1 rdf:type owl:Class .
_:c1 owl:intersectionOf _:c2 .
_:c2 rdf:first ub:GraduateStudent .
_:c2 rdf:rest _:c3 .
_:c3 rdf:first ub:UndergraduateStudent .
_:c3 rdf:rest rdf:nil .

Note that Konclude also supports existential variables in conjunctive queries (represented as RDF blank nodes in SPARQL queries). For example, Konclude only checks for the variable :_y in the following query wether a potentially anonymous/implied individual exists for an answer candidate for ?X and ?Z and only then returns the candidate as an answer:

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ub: <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>
?X ub:advisor :_y .
:_y rdf:type ub:Faculty .
:_y ub:teacherOf ?Z .
?Z rdf:type ub:Course .
?X ub:takesCourse ?Z .

Using existential variables can be more expensive and there is a (very small) possibility that the query answering does not terminate if the ontology uses inverse roles, cardinality restrictions and nominals. Please also note that not literals may not completely be supported and only partially indexed. In general, however, the query answering engine of Konclude supports parallelization, i.e., starting Konclude with several worker threads (via parameter '-w NUMBER_OF_WORKERS') should speed up query answering significantly. Konclude uses an intermediate results cache, which can be limited via the config 'Konclude.Answering.AnswersCacheMaximumSizeBytes'. For example, the command line

 > Konclude sparqlserver +=Konclude.Answering.AnswersCacheMaximumSizeBytes=1073741824

limits the cache to 1 GByte (1024 * 1024 * 1024 = 1073741824), i.e., if the cache limit is reached, then Konclude starts deleting (intermedidate) results that are less often used and less costly to compute until it is under the limit again.

SPARQL Results

To send SPARQL queries to Konclude via HTTP POST, you may want to use the 'curl' command line tool (comes with Linux or OS X and available also for Windows at cURL) as follows:

 > curl --data "@Tests/query.sparql" http:⁄⁄localhost:8080 

Note that Konclude streams the results via chunked HTTP transfer encoding in the XML Result Format, i.e., it must be supported by the client to correctly retrieve (all) answers.