On 11/10/14 16:35, Daniel Ferreira (theiostream) wrote:
Hi,
I'm new to Jena, and I've been able to get around the platform looking at
the documentation fairly nicely, but I couldn't find a solution to the
following:
I would be able to make a query like:
SELECT ?subfunction WHERE {
?subject x:function x:knownFunction .
?subject x:subfunction ?subfunction
}
Here, a subject holds a "function" and a "subfunction". In this query, I'd
select all subjects with a determined function and within those subjects
list their subfunctions, therefore being able to list all subfunctions for
determined function, something that wouldn't be able to be queried directly.
Using Jena models, I'd be able to perform .listStatements() to find all
subjects that have determined function, but I wouldn't be able to find the
subfunctions among them. Is there a way of doing it with the Model API, or
would I really have to perform a query or iterate through found statements
and find, for each item, a subfunction?
There isn't a single API call that will do the multiple accesses needed.
You can do the latter - loop over "x:function" matches looking for
"x:subfunction". This is one of the options ARQ has in executing that
query - an indexed join.
As "?subject x:function x:knownFunction" has two grounded terms and
"?subject x:subfunction ?subfunction" has one, ARQ will execute the
pattern in the order you've written it, effectively as an iteration over
the first pattern, looking for
"<subject> x:subfunction ?subfunction" for each <subject> from
?subject x:function x:knownFunction .
Andy
Thank you,
Daniel.