You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Hashim Khan <en...@gmail.com> on 2023/09/19 11:20:11 UTC
Query features info
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*
Re: Query features info
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
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 buehmann@infai.org
Institute for Applied Informatics e.V. (InfAI) | Goerdelerring 9 | 04109 Leipzig | Germany
Re: Re: Query features info
Posted by Hashim Khan <en...@gmail.com>.
Thanks Lorenz and James for the feedback and clarification.
The paper I am talking about is
https://www.semantic-web-journal.net/system/files/swj3336.pdf
Best Regards,
Hashim
On Thu, Sep 21, 2023 at 8:21 AM Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> @Hashim in the future you should reply to the mailing list such that all
> people can see your response and follow the thread. Now we can just see
> your answer because James replied to you and the mailing list. We also
> can't see your attachment.
>
> Which paper are you talking about?
>
> As James said, there is a difference between a syntax tree like the Jena
> algebra tree does (without optimizations) and a query execution plan
> (with optimizations).
>
>
> Regarding LSQ, given that you're working at DICE group, I'd suggest to
> have a look at it or simply talk to Saleem. But it does only extract the
> "simple" features based on the syntax tree and makes it accessible as
> RDF data itself.
>
> Lorenz
>
> On 20.09.23 23:05, James Anderson wrote:
> > good evening;
> >
> > if you want to reproduce those results, you will have to examine the
> parsed syntax tree.
> > that should comprise just two bgps, as that is the immediate syntax.
> > if, on the other hand, you examaine the results of a query planner, you
> are not looking at a systax tree, you are looking at the query processor's
> prospective exection plan.
> > execution model permits the transformations to which i alluded.
> > you will more likely get your desired representation by having jena emit
> an sse, rather than an execution plan.
> >
> > best regards, from berlin,
> >
> >> On 20. Sep 2023, at 17:48, Hashim Khan <en...@gmail.com>
> wrote:
> >>
> >> Thanks for the quick reply.
> >>
> >> To be precise, I want to clarify the table on page 7 of the attached
> paper. Here, the No. of BGPs is 2, and also some more values. I want to
> extract all the info using Jena. But I could not till now. About the LSQ, I
> will check it, but I am following this paper and want to reproduce the
> results.
> >>
> >> Best Regards,
> >> Hashim
> >>
> >> On Tue, Sep 19, 2023 at 4:18 PM James Anderson <
> anderson.james.1955@gmail.com> wrote:
> >> good afternoon;
> >>
> >> you have to consider that a query processor is free to consolidate
> statement patterns in a nominal bgp - which itself implicitly joins them,
> or separate them in order to either apply a different join strategy or - as
> in this case, to interleave an operation under the suspicion that it will
> reduce solution set cardinality.
> >>
> >> best regards, from berlin,
> >>
> >>> On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com>
> 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*
> >> ---
> >> james anderson | james@dydra.com | https://dydra.com
> >>
> >>
> >>
> >>
> >> --
> >> Hashim Khan
> >>
> >> <swj3336.pdf>
> > ---
> > james anderson | james@dydra.com | https://dydra.com
> >
> >
> >
> --
> Lorenz Bühmann
> Research Associate/Scientific Developer
>
> Email buehmann@infai.org
>
> Institute for Applied Informatics e.V. (InfAI) | Goerdelerring 9 | 04109
> Leipzig | Germany
>
>
--
*Hashim Khan*
Re: Re: Query features info
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
@Hashim in the future you should reply to the mailing list such that all
people can see your response and follow the thread. Now we can just see
your answer because James replied to you and the mailing list. We also
can't see your attachment.
Which paper are you talking about?
As James said, there is a difference between a syntax tree like the Jena
algebra tree does (without optimizations) and a query execution plan
(with optimizations).
Regarding LSQ, given that you're working at DICE group, I'd suggest to
have a look at it or simply talk to Saleem. But it does only extract the
"simple" features based on the syntax tree and makes it accessible as
RDF data itself.
Lorenz
On 20.09.23 23:05, James Anderson wrote:
> good evening;
>
> if you want to reproduce those results, you will have to examine the parsed syntax tree.
> that should comprise just two bgps, as that is the immediate syntax.
> if, on the other hand, you examaine the results of a query planner, you are not looking at a systax tree, you are looking at the query processor's prospective exection plan.
> execution model permits the transformations to which i alluded.
> you will more likely get your desired representation by having jena emit an sse, rather than an execution plan.
>
> best regards, from berlin,
>
>> On 20. Sep 2023, at 17:48, Hashim Khan <en...@gmail.com> wrote:
>>
>> Thanks for the quick reply.
>>
>> To be precise, I want to clarify the table on page 7 of the attached paper. Here, the No. of BGPs is 2, and also some more values. I want to extract all the info using Jena. But I could not till now. About the LSQ, I will check it, but I am following this paper and want to reproduce the results.
>>
>> Best Regards,
>> Hashim
>>
>> On Tue, Sep 19, 2023 at 4:18 PM James Anderson <an...@gmail.com> wrote:
>> good afternoon;
>>
>> you have to consider that a query processor is free to consolidate statement patterns in a nominal bgp - which itself implicitly joins them, or separate them in order to either apply a different join strategy or - as in this case, to interleave an operation under the suspicion that it will reduce solution set cardinality.
>>
>> best regards, from berlin,
>>
>>> On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com> 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*
>> ---
>> james anderson | james@dydra.com | https://dydra.com
>>
>>
>>
>>
>> --
>> Hashim Khan
>>
>> <swj3336.pdf>
> ---
> james anderson | james@dydra.com | https://dydra.com
>
>
>
--
Lorenz Bühmann
Research Associate/Scientific Developer
Email buehmann@infai.org
Institute for Applied Informatics e.V. (InfAI) | Goerdelerring 9 | 04109 Leipzig | Germany
Re: Query features info
Posted by Hashim Khan <en...@gmail.com>.
Thanks a lot Rob,
Yes, the hint given by James "*jena emit an sse, rather than an execution
plan*" has worked and I got the desired results, i.e through the command
you mentioned. ./qparse --print=op --file exampleQuery.sparql ...
About the "*arq --optimize=off or off --query exampleQuery.sparql --explain*"
let me try some more queries to actually feel the difference here. I thank
you all for helping me.
Best Regards.
Hashim
On Thu, Sep 21, 2023 at 11:22 AM Rob @ DNR <rv...@dotnetrdf.org> wrote:
> Hashim
>
> I think what you want is probably --optimize=off and that should yield you
> the expected two BGPs e.g.
>
>
> arq --optimize=off --query exampleQuery.sparql --explain
>
>
> 09:43:57 INFO exec :: ALGEBRA
>
> (slice _ 100
>
> (distinct
>
> (project (?name ?birth ?death)
>
> (filter (< ?birth "1900-01-01")
>
> (leftjoin
>
> (bgp
>
> (triple ?person http://dbpedia.org/ontology/birthPlace
> http://dbpedia.org/resource/Berlin)
>
> (triple ?person http://dbpedia.org/ontology/birthDate
> ?birth)
>
> (triple ?person http://xmlns.com/foaf/0.1/name ?name)
>
> )
>
> (bgp (triple ?person http://dbpedia.org/ontology/deathDate
> ?death)))))))
>
>
>
> As James noted query engines are free to apply optimisations to the raw
> algebra of the query provided that those optimisations preserve the
> semantics of the query. Jena’s ARQ query engine contains many of these
> that have been developed over many years based on implementation
> experience, academic papers, applying well known query optimisation
> techniques etc.
>
>
>
> Note that turning optimisations off (whatever engine you are using) is
> rarely a good idea.
>
> You may want to experiment with the qparse command whose --print option
> allows you to ask to see various forms of the query from the perspective of
> Jena’a ARQ engine. For example, the following shows the raw algebra and
> the optimised algebra in the same output.
>
> qparse --query exampleQuery.sparql --print=op --print=optquad
>
>
>
> (prefix ((dbo: http://dbpedia.org/ontology/)
>
> (dbr: http://dbpedia.org/resource/)
>
> (foaf: http://xmlns.com/foaf/0.1/))
>
> (slice _ 100
>
> (distinct
>
> (project (?name ?birth ?death)
>
> (filter (< ?birth "1900-01-01")
>
> (leftjoin
>
> (bgp
>
> (triple ?person dbo:birthPlace dbr:Berlin)
>
> (triple ?person dbo:birthDate ?birth)
>
> (triple ?person foaf:name ?name)
>
> )
>
> (bgp (triple ?person dbo:deathDate ?death))))))))
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>
> (prefix ((dbo: http://dbpedia.org/ontology/)
>
> (dbr: http://dbpedia.org/resource/)
>
> (foaf: http://xmlns.com/foaf/0.1/))
>
> (slice _ 100
>
> (distinct
>
> (project (?name ?birth ?death)
>
> (conditional
>
> (sequence
>
> (filter (< ?birth "1900-01-01")
>
> (quadpattern
>
> (quad <urn:x-arq:DefaultGraphNode> ?person dbo:birthPlace
> dbr:Berlin)
>
> (quad <urn:x-arq:DefaultGraphNode> ?person dbo:birthDate
> ?birth)
>
> ))
>
> (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?person
> foaf:name ?name)))
>
> (quadpattern (quad <urn:x-arq:DefaultGraphNode> ?person
> dbo:deathDate ?death)))))))
>
>
>
> Hope this helps,
>
>
>
> Rob
>
> From: James Anderson <an...@gmail.com>
> Date: Wednesday, 20 September 2023 at 22:06
> To: Hashim Khan <en...@gmail.com>
> Cc: users@jena.apache.org <us...@jena.apache.org>
> Subject: Re: Query features info
> good evening;
>
> if you want to reproduce those results, you will have to examine the
> parsed syntax tree.
> that should comprise just two bgps, as that is the immediate syntax.
> if, on the other hand, you examaine the results of a query planner, you
> are not looking at a systax tree, you are looking at the query processor's
> prospective exection plan.
> execution model permits the transformations to which i alluded.
> you will more likely get your desired representation by having jena emit
> an sse, rather than an execution plan.
>
> best regards, from berlin,
>
> > On 20. Sep 2023, at 17:48, Hashim Khan <en...@gmail.com>
> wrote:
> >
> > Thanks for the quick reply.
> >
> > To be precise, I want to clarify the table on page 7 of the attached
> paper. Here, the No. of BGPs is 2, and also some more values. I want to
> extract all the info using Jena. But I could not till now. About the LSQ, I
> will check it, but I am following this paper and want to reproduce the
> results.
> >
> > Best Regards,
> > Hashim
> >
> > On Tue, Sep 19, 2023 at 4:18 PM James Anderson <
> anderson.james.1955@gmail.com> wrote:
> > good afternoon;
> >
> > you have to consider that a query processor is free to consolidate
> statement patterns in a nominal bgp - which itself implicitly joins them,
> or separate them in order to either apply a different join strategy or - as
> in this case, to interleave an operation under the suspicion that it will
> reduce solution set cardinality.
> >
> > best regards, from berlin,
> >
> > > On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com>
> 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>)<
> http://dbpedia.org/resource/Berlin%3e)>
> > > (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><
> http://dbpedia.org/resource/Berlin%3e>
> > > ?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><
> http://dbpedia.org/resource/Berlin%3e>
> > > ?person <http://dbpedia.org/ontology/birthDate> ?birth
> > > 13:11:41 INFO exec :: BGP :: ?person <
> > > http://xmlns.com/foaf/0.1/name><http://xmlns.com/foaf/0.1/name%3e>
> ?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*
> >
> > ---
> > james anderson | james@dydra.com | https://dydra.com
> >
> >
> >
> >
> > --
> > Hashim Khan
> >
> > <swj3336.pdf>
>
> ---
> james anderson | james@dydra.com | https://dydra.com
>
>
--
*Hashim Khan*
Re: Query features info
Posted by "Rob @ DNR" <rv...@dotnetrdf.org>.
Hashim
I think what you want is probably --optimize=off and that should yield you the expected two BGPs e.g.
arq --optimize=off --query exampleQuery.sparql --explain
09:43:57 INFO exec :: ALGEBRA
(slice _ 100
(distinct
(project (?name ?birth ?death)
(filter (< ?birth "1900-01-01")
(leftjoin
(bgp
(triple ?person http://dbpedia.org/ontology/birthPlace http://dbpedia.org/resource/Berlin)
(triple ?person http://dbpedia.org/ontology/birthDate ?birth)
(triple ?person http://xmlns.com/foaf/0.1/name ?name)
)
(bgp (triple ?person http://dbpedia.org/ontology/deathDate ?death)))))))
As James noted query engines are free to apply optimisations to the raw algebra of the query provided that those optimisations preserve the semantics of the query. Jena’s ARQ query engine contains many of these that have been developed over many years based on implementation experience, academic papers, applying well known query optimisation techniques etc.
Note that turning optimisations off (whatever engine you are using) is rarely a good idea.
You may want to experiment with the qparse command whose --print option allows you to ask to see various forms of the query from the perspective of Jena’a ARQ engine. For example, the following shows the raw algebra and the optimised algebra in the same output.
qparse --query exampleQuery.sparql --print=op --print=optquad
(prefix ((dbo: http://dbpedia.org/ontology/)
(dbr: http://dbpedia.org/resource/)
(foaf: http://xmlns.com/foaf/0.1/))
(slice _ 100
(distinct
(project (?name ?birth ?death)
(filter (< ?birth "1900-01-01")
(leftjoin
(bgp
(triple ?person dbo:birthPlace dbr:Berlin)
(triple ?person dbo:birthDate ?birth)
(triple ?person foaf:name ?name)
)
(bgp (triple ?person dbo:deathDate ?death))))))))
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(prefix ((dbo: http://dbpedia.org/ontology/)
(dbr: http://dbpedia.org/resource/)
(foaf: http://xmlns.com/foaf/0.1/))
(slice _ 100
(distinct
(project (?name ?birth ?death)
(conditional
(sequence
(filter (< ?birth "1900-01-01")
(quadpattern
(quad <urn:x-arq:DefaultGraphNode> ?person dbo:birthPlace dbr:Berlin)
(quad <urn:x-arq:DefaultGraphNode> ?person dbo:birthDate ?birth)
))
(quadpattern (quad <urn:x-arq:DefaultGraphNode> ?person foaf:name ?name)))
(quadpattern (quad <urn:x-arq:DefaultGraphNode> ?person dbo:deathDate ?death)))))))
Hope this helps,
Rob
From: James Anderson <an...@gmail.com>
Date: Wednesday, 20 September 2023 at 22:06
To: Hashim Khan <en...@gmail.com>
Cc: users@jena.apache.org <us...@jena.apache.org>
Subject: Re: Query features info
good evening;
if you want to reproduce those results, you will have to examine the parsed syntax tree.
that should comprise just two bgps, as that is the immediate syntax.
if, on the other hand, you examaine the results of a query planner, you are not looking at a systax tree, you are looking at the query processor's prospective exection plan.
execution model permits the transformations to which i alluded.
you will more likely get your desired representation by having jena emit an sse, rather than an execution plan.
best regards, from berlin,
> On 20. Sep 2023, at 17:48, Hashim Khan <en...@gmail.com> wrote:
>
> Thanks for the quick reply.
>
> To be precise, I want to clarify the table on page 7 of the attached paper. Here, the No. of BGPs is 2, and also some more values. I want to extract all the info using Jena. But I could not till now. About the LSQ, I will check it, but I am following this paper and want to reproduce the results.
>
> Best Regards,
> Hashim
>
> On Tue, Sep 19, 2023 at 4:18 PM James Anderson <an...@gmail.com> wrote:
> good afternoon;
>
> you have to consider that a query processor is free to consolidate statement patterns in a nominal bgp - which itself implicitly joins them, or separate them in order to either apply a different join strategy or - as in this case, to interleave an operation under the suspicion that it will reduce solution set cardinality.
>
> best regards, from berlin,
>
> > On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com> 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>)<http://dbpedia.org/resource/Berlin%3e)>
> > (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><http://dbpedia.org/resource/Berlin%3e>
> > ?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><http://dbpedia.org/resource/Berlin%3e>
> > ?person <http://dbpedia.org/ontology/birthDate> ?birth
> > 13:11:41 INFO exec :: BGP :: ?person <
> > http://xmlns.com/foaf/0.1/name><http://xmlns.com/foaf/0.1/name%3e> ?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*
>
> ---
> james anderson | james@dydra.com | https://dydra.com
>
>
>
>
> --
> Hashim Khan
>
> <swj3336.pdf>
---
james anderson | james@dydra.com | https://dydra.com
Re: Query features info
Posted by James Anderson <an...@gmail.com>.
good evening;
if you want to reproduce those results, you will have to examine the parsed syntax tree.
that should comprise just two bgps, as that is the immediate syntax.
if, on the other hand, you examaine the results of a query planner, you are not looking at a systax tree, you are looking at the query processor's prospective exection plan.
execution model permits the transformations to which i alluded.
you will more likely get your desired representation by having jena emit an sse, rather than an execution plan.
best regards, from berlin,
> On 20. Sep 2023, at 17:48, Hashim Khan <en...@gmail.com> wrote:
>
> Thanks for the quick reply.
>
> To be precise, I want to clarify the table on page 7 of the attached paper. Here, the No. of BGPs is 2, and also some more values. I want to extract all the info using Jena. But I could not till now. About the LSQ, I will check it, but I am following this paper and want to reproduce the results.
>
> Best Regards,
> Hashim
>
> On Tue, Sep 19, 2023 at 4:18 PM James Anderson <an...@gmail.com> wrote:
> good afternoon;
>
> you have to consider that a query processor is free to consolidate statement patterns in a nominal bgp - which itself implicitly joins them, or separate them in order to either apply a different join strategy or - as in this case, to interleave an operation under the suspicion that it will reduce solution set cardinality.
>
> best regards, from berlin,
>
> > On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com> 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*
>
> ---
> james anderson | james@dydra.com | https://dydra.com
>
>
>
>
> --
> Hashim Khan
>
> <swj3336.pdf>
---
james anderson | james@dydra.com | https://dydra.com
Re: Query features info
Posted by James Anderson <an...@gmail.com>.
good afternoon;
you have to consider that a query processor is free to consolidate statement patterns in a nominal bgp - which itself implicitly joins them, or separate them in order to either apply a different join strategy or - as in this case, to interleave an operation under the suspicion that it will reduce solution set cardinality.
best regards, from berlin,
> On 19. Sep 2023, at 13:20, Hashim Khan <en...@gmail.com> 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*
---
james anderson | james@dydra.com | https://dydra.com