Hi,
getting the data you're interested in needs to traverse either the
algebra (which is shown in your "explain" request) or the query
structure. For both you'll have to write Java code - luckily Jena
already provides the necessary tools via visitors.
By the way, why do you think there are only two BGPs? I mean the number
of triple patterns in the query is clearly not 2, right?
PS: did you check out the LSQ project resp. the LSQ code? I think there
is already some SPARQL query feature extraction code somewhere in the
framework.
Lorenz
On 19.09.23 13:20, Hashim Khan wrote:
Hi,
Having a look on this SPARQL query:
---------------------------------------------------------------------------
prefix dbo:<http://dbpedia.org/ontology/>
prefix dbr:<http://dbpedia.org/resource/>
prefix foaf:<http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?name ?birth ?death
WHERE { ?person dbo:birthPlace dbr:Berlin .
?person dbo:birthDate ?birth .
?person foaf:name ?name .
OPTIONAL { ?person dbo:deathDate ?death . }
FILTER (?birth < "1900-01-01") .
}
LIMIT 100
-----------------------------------------------------------------------------
Using Apache Jena ARQ command, ./arq --query exampleQuery.sparql --explain
I got this result.
13:11:41 INFO exec :: ALGEBRA
(slice _ 100
(distinct
(project (?name ?birth ?death)
(conditional
(sequence
(filter (< ?birth "1900-01-01")
(bgp
(triple ?person <http://dbpedia.org/ontology/birthPlace> <
http://dbpedia.org/resource/Berlin>)
(triple ?person <http://dbpedia.org/ontology/birthDate>
?birth)
))
(bgp (triple ?person <http://xmlns.com/foaf/0.1/name> ?name)))
(bgp (triple ?person <http://dbpedia.org/ontology/deathDate>
?death))))))
13:11:41 INFO exec :: BGP
?person <http://dbpedia.org/ontology/birthPlace> <
http://dbpedia.org/resource/Berlin>
?person <http://dbpedia.org/ontology/birthDate> ?birth
13:11:41 INFO exec :: Reorder/generic
?person <http://dbpedia.org/ontology/birthPlace> <
http://dbpedia.org/resource/Berlin>
?person <http://dbpedia.org/ontology/birthDate> ?birth
13:11:41 INFO exec :: BGP :: ?person <
http://xmlns.com/foaf/0.1/name> ?name
------------------------
| name | birth | death |
========================
------------------------ I have a question about the Basic Graph Patterns.
I think, in this query there are two BGPs. But here i shows 3. Can anyone
explain it to me? Also, I want to know, the number of joins, no of
projection variables, number of left joins, depth, and such other relevant
info about the query features. How can I get all at one place?
Best Regards,
*Hashim Khan*
--
Lorenz Bühmann
Research Associate/Scientific Developer
Email [email protected]
Institute for Applied Informatics e.V. (InfAI) | Goerdelerring 9 | 04109
Leipzig | Germany