Aha, a GROUP BY opportunity? (ignoring the filter on predicate for now)

  ?r rdf:subject <urn:jug:00021a4501bfda090b3a95919c235744#e72> .
  ?r rdf:object ?o .
  ?r rdf:predicate ?p .

If I group by (O, P) and count, I can get results like  U(=that long
uri) ?O ?P ?COUNT, if the relational analogy holds, no?



On Thu, Jan 6, 2011 at 2:32 PM, Benson Margulies <[email protected]> wrote:
> With current ARQ, the default syntax didn't accept count. I set syntax
> to ARQ and it worked. I'll change it to use the sparql 1.1 syntax
> instead.
>
> On Thu, Jan 6, 2011 at 2:06 PM, Andy Seaborne
> <[email protected]> wrote:
>>
>>
>> On 06/01/11 18:47, Benson Margulies wrote:
>>>
>>> In my store I have (for purposes of discussion)
>>>
>>> one tuple S P O
>>>
>>> and then some number of quadlets on it.
>>>
>>> I want to find out how many.
>>
>> SELECT (Count(*) AS ?C)
>> {
>>   ?x rdf:subject S .
>>   ?x rdf:predicate P .
>>   ?x rdf:object O .
>> }
>>
>> which assumes fully reified.
>>
>>> However, to make matters more complex, what I'd really like to do is
>>> set up a construct query that finds
>>>
>>>
>>> S (p1|p2|p3|p4...) O
>>
>> SELECT (Count(*) AS ?C)
>> {
>>   ?x rdf:subject S .
>>   ?x rdf:predicate ?P .
>>   ?x rdf:object O .
>>   FILTER ( ?P IN ( p1, p2, p3, p4) )
>> }
>>
>>
>>> and also then returns the count of quadlets for each of these it comes up
>>> with.
>>
>> Finding then counting, and finding and returning needs duplication of the
>> thing.  It's a quirk in the whole relation algebra thing  - you can't assign
>> subexpressions and reuse them - this is not unique to SPARQL.  To look at it
>> another way, counting is destructive on the things being counted.
>>
>>> Is this plausible .... ? Obviously, I can do it by first finding the
>>> statements and then going back and using the COUNT extension to do the
>>> counting.
>>
>> COUNT isn't an extension - it's part of SPARQL 1.1
>>
>>> Is TDB particularly good or bad at this?
>>
>> It does not anything special but caching is your friend (and mime).
>>
>>        Andy
>>
>

Reply via email to