On 24/03/13 21:12, Diogo FC Patrao wrote:
Hi Andy
In any case, why is there the need for the assign node? Why not simply:
(project (?p ?asvar)
(group (?p) ((?asvar (count ?b)))
Each aggregate is done once, even if used multiple times:
1/ ==>
SELECT (count(*) AS ?x) (1/count(*) AS ?y) { .. }
2/ ==>
SELECT (avg(?o) AS ?x)
{ ?s ?p ?o }
GROUP BY ?s
HAVING ( avg(?o) > 156 )
and (extend) which is used in the current ARQ, not (assign), is very
cheap in ARQ.
Andy
--
diogo patrĂ£o
On Sun, Mar 24, 2013 at 2:54 PM, Andy Seaborne <[email protected]> wrote:
On 22/03/13 17:43, Damian Steer wrote:
On 22 Mar 2013, at 17:01, Diogo FC Patrao <[email protected]> wrote:
I'm rendering back the query, implementing the OpAsQuery missing methods.
However I got another doubt, check the query below:
select ?p count( ?b ) { ?p a <http://marafo.com#Paciente>. ?a <
http://marafo.com#tem> ?b. LET ( ?marafo := ?b+1 ) } group by ?p
The generated algebra is:
(project (?p ?.1)
(assign ((?.1 ?.0))
(group (?p) ((?.0 (count ?b)))
I didn't get why is there this "(assign (?.1 ?.0) ) " thing... can
someone
enlighten me?
AFAIK it's simply an artifact of way the compiler works.
OpAsQuery handles this by remembering the aggregation as it goes (in
varExpression) and undoes the split later:
<https://github.com/apache/**jena/blob/trunk/jena-arq/src/**
main/java/com/hp/hpl/jena/**sparql/algebra/OpAsQuery.java#**L523<https://github.com/apache/jena/blob/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java#L523>
<https://github.com/apache/**jena/blob/trunk/jena-arq/src/**
main/java/com/hp/hpl/jena/**sparql/algebra/OpAsQuery.java#**L56<https://github.com/apache/jena/blob/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java#L56>
Damian
Here, it's not SPARQL 1.1 because there is no AS on the count(?b)
otherwise the (assign) would be (assign ((?AS_VAR ?.0)). The ?.1 is a
generated variable for the lack of AS with count().
Andy