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