You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@clerezza.apache.org by Minto van der Sluis <mi...@xup.nl> on 2013/01/06 11:09:24 UTC
Query over multiple named graphs
Hi folks,
Currently I am using clerezza with a Jena TDB storage backend to store
multiple named graphs.
Now I wonder how to perform a query over these named graphs. I can use
the following command:
TcManager.executeSparqlQuery( query, ? )
But what should be used as the triple collection? If the default graph,
how do I specify that?
Regards,
Minto van der Sluis
Software innovator / renovator
Xup BV
Re: Query over multiple named graphs
Posted by Minto van der Sluis <mi...@xup.nl>.
Thanks for you answer Tommaso.
But somehow I sense that this is not the right solution for me. This is
for a few reasons:
1) A UnionMGraph constructor needs all (sub) Graphs in advance. I could
not find a way to dynamically add another graph after construction. As a
result I have to recreate the union every time after a new named graph
is created.
2) The graph name is lost when added to the union.
3) If I am correct a UnioinMGraph is treated as a single graph. Somehow
I fear that using queries on the UnionMGraph do not take the sparql
GRAPH keyword into account properly.
4) Creating unions all the time does not seem to scale very well. In my
case I will have a large number of named graphs.
Looking at Apache Jena, I read the following: "An RDF Dataset
<http://www.w3.org/TR/sparql11-query/#rdfDataset> is a collection of
one, unnamed, default graph and zero, or more named graphs. In a SPARQL
query, a query pattern is matched against the default graph unless the
GRAPH keyword is applied to a pattern." (
http://jena.apache.org/documentation/tdb/datasets.html )
According to CLEREZZA-467 it seams this Jena feature is lost when using
Clerezza's sparql capabilities. The way I see it, and please correct me
if I am wrong, I have the following options:
1) Go native Jena for doing queries over named graphs. According to
CLEREZZA-467 I probably have to go native as well for storing graphs.
This is due to MGraphs being stored in isolated datasets. In my case
this is almost equal to abondoning clerezza.
2) Wait for sparql fastlane, CLEREZZA-468, to be completed. Is anyone
actually working on this? Besides I do not have the luxury to wait :-(
3) Start working on sparql fastlane. For this I fear the amount of work
heading my way, but more importantly the amount of time it would take.
Does anyone have a vague idea how much time this would take?
I favour option 3 but am afraid that I will end up with option 1 :-(
Are there any other options?
Related Jira issues:
https://issues.apache.org/jira/browse/CLEREZZA-466
https://issues.apache.org/jira/browse/CLEREZZA-467
https://issues.apache.org/jira/browse/CLEREZZA-468
Regards,
Minto
Op 8-1-2013 8:53, Tommaso Teofili schreef:
> Hi Minto,
>
> I think that you should use a union graph (UnionMGraph) over your
> underlying named graphs and that should work as expected.
>
> I hope this helps,
> Tommaso
>
>
> 2013/1/6 Minto van der Sluis <mi...@xup.nl>
>
>> Hi folks,
>>
>> Currently I am using clerezza with a Jena TDB storage backend to store
>> multiple named graphs.
>>
>> Now I wonder how to perform a query over these named graphs. I can use
>> the following command:
>>
>> TcManager.executeSparqlQuery( query, ? )
>>
>> But what should be used as the triple collection? If the default graph,
>> how do I specify that?
>>
>> Regards,
>>
>> Minto van der Sluis
>> Software innovator / renovator
>> Xup BV
Re: Query over multiple named graphs
Posted by Andy Seaborne <an...@apache.org>.
On 08/01/13 15:05, Minto van der Sluis wrote:
> Hi Reto,
>
> Thanks for your answer.
>
> It's not that I want to merge multiple named graphs together to perform
> a query. I already achieved that as a workaround by adding new triples
> to both a named graph and a default graph. Like this I can query the
> default graph.
>
> What I actually try to achieve is find all named graphs the meet certain
> requirements. For instance the following simple query to return then
> names of all named graph.
>
> |SELECT DISTINCT ?g
> WHERE {
> GRAPH ?g {
> ?s ?p ?o
> }
> }|
>
a better query is:
SELECT ?g { GRAPH ?g {} }
Andy
>
> This query contains no FROM clause. So I guess the supplied graph
> (second argument) is still used.
>
> The workaround I currently use is satisfactory for the time being, but
> does not meet the requirements I have for the near future. So I have to
> come up with something one way or another.
>
> Regards,
>
> Minto
>
> Op 8-1-2013 14:16, Reto Bachmann-Gmür schreef:
>> Hi Minto,
>>
>> The defaultGraph passed as second argument is ignered if a FROM clause is
>> present in your query, otherwise this is used as default Graph and other
>> graphs can be access using "FROM NAMED".
>>
>> If you want to rund your query about afainst the union of several graphs
>> you should use UnionMGraph as Tommaso pointed out. If this is your usecase
>> we should keep this in mind for the fast-lane to be implemented.
>>
>> Cheers,
>> Reto
>>
>> On Tue, Jan 8, 2013 at 8:53 AM, Tommaso Teofili
>> <to...@gmail.com>wrote:
>>
>>> Hi Minto,
>>>
>>> I think that you should use a union graph (UnionMGraph) over your
>>> underlying named graphs and that should work as expected.
>>>
>>> I hope this helps,
>>> Tommaso
>>>
>>>
>>> 2013/1/6 Minto van der Sluis <mi...@xup.nl>
>>>
>>>> Hi folks,
>>>>
>>>> Currently I am using clerezza with a Jena TDB storage backend to store
>>>> multiple named graphs.
>>>>
>>>> Now I wonder how to perform a query over these named graphs. I can use
>>>> the following command:
>>>>
>>>> TcManager.executeSparqlQuery( query, ? )
>>>>
>>>> But what should be used as the triple collection? If the default graph,
>>>> how do I specify that?
>>>>
>>>> Regards,
>>>>
>>>> Minto van der Sluis
>>>> Software innovator / renovator
>>>> Xup BV
>>>>
>
>
Re: Query over multiple named graphs
Posted by Minto van der Sluis <mi...@xup.nl>.
Hi,
It worked :-)
Now I can stick with Clerezza.
With red cheeks I have to admit that the reason it did not work at first
was probably my own fault.
Regards and thanks for all the help.
Minto
Op 8-1-2013 18:04, Reto Bachmann-Gmür schreef:
> Hi Minto
>
> What I actually try to achieve is find all named graphs the meet certain
>
>> requirements. For instance the following simple query to return then
>> names of all named graph.
>>
>> |SELECT DISTINCT ?g
>> WHERE {
>> GRAPH ?g {
>> ?s ?p ?o
>> }
>> }|
>>
>> What happens if you set an arbitary graph from TcManager as second
> argument or just a new SimpleMGraph() ?
>
> Cheers,
> Reto
>
--
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV
Mobiel: +31 (0) 626 014541
Re: Query over multiple named graphs
Posted by Reto Bachmann-Gmür <re...@apache.org>.
Hi Minto
What I actually try to achieve is find all named graphs the meet certain
> requirements. For instance the following simple query to return then
> names of all named graph.
>
> |SELECT DISTINCT ?g
> WHERE {
> GRAPH ?g {
> ?s ?p ?o
> }
> }|
>
> What happens if you set an arbitary graph from TcManager as second
argument or just a new SimpleMGraph() ?
Cheers,
Reto
Re: Query over multiple named graphs
Posted by Minto van der Sluis <mi...@xup.nl>.
Hi Reto,
Thanks for your answer.
It's not that I want to merge multiple named graphs together to perform
a query. I already achieved that as a workaround by adding new triples
to both a named graph and a default graph. Like this I can query the
default graph.
What I actually try to achieve is find all named graphs the meet certain
requirements. For instance the following simple query to return then
names of all named graph.
|SELECT DISTINCT ?g
WHERE {
GRAPH ?g {
?s ?p ?o
}
}|
This query contains no FROM clause. So I guess the supplied graph
(second argument) is still used.
The workaround I currently use is satisfactory for the time being, but
does not meet the requirements I have for the near future. So I have to
come up with something one way or another.
Regards,
Minto
Op 8-1-2013 14:16, Reto Bachmann-Gmür schreef:
> Hi Minto,
>
> The defaultGraph passed as second argument is ignered if a FROM clause is
> present in your query, otherwise this is used as default Graph and other
> graphs can be access using "FROM NAMED".
>
> If you want to rund your query about afainst the union of several graphs
> you should use UnionMGraph as Tommaso pointed out. If this is your usecase
> we should keep this in mind for the fast-lane to be implemented.
>
> Cheers,
> Reto
>
> On Tue, Jan 8, 2013 at 8:53 AM, Tommaso Teofili
> <to...@gmail.com>wrote:
>
>> Hi Minto,
>>
>> I think that you should use a union graph (UnionMGraph) over your
>> underlying named graphs and that should work as expected.
>>
>> I hope this helps,
>> Tommaso
>>
>>
>> 2013/1/6 Minto van der Sluis <mi...@xup.nl>
>>
>>> Hi folks,
>>>
>>> Currently I am using clerezza with a Jena TDB storage backend to store
>>> multiple named graphs.
>>>
>>> Now I wonder how to perform a query over these named graphs. I can use
>>> the following command:
>>>
>>> TcManager.executeSparqlQuery( query, ? )
>>>
>>> But what should be used as the triple collection? If the default graph,
>>> how do I specify that?
>>>
>>> Regards,
>>>
>>> Minto van der Sluis
>>> Software innovator / renovator
>>> Xup BV
>>>
--
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV
Mobiel: +31 (0) 626 014541
Re: Query over multiple named graphs
Posted by Reto Bachmann-Gmür <re...@apache.org>.
Hi Minto,
The defaultGraph passed as second argument is ignered if a FROM clause is
present in your query, otherwise this is used as default Graph and other
graphs can be access using "FROM NAMED".
If you want to rund your query about afainst the union of several graphs
you should use UnionMGraph as Tommaso pointed out. If this is your usecase
we should keep this in mind for the fast-lane to be implemented.
Cheers,
Reto
On Tue, Jan 8, 2013 at 8:53 AM, Tommaso Teofili
<to...@gmail.com>wrote:
> Hi Minto,
>
> I think that you should use a union graph (UnionMGraph) over your
> underlying named graphs and that should work as expected.
>
> I hope this helps,
> Tommaso
>
>
> 2013/1/6 Minto van der Sluis <mi...@xup.nl>
>
> > Hi folks,
> >
> > Currently I am using clerezza with a Jena TDB storage backend to store
> > multiple named graphs.
> >
> > Now I wonder how to perform a query over these named graphs. I can use
> > the following command:
> >
> > TcManager.executeSparqlQuery( query, ? )
> >
> > But what should be used as the triple collection? If the default graph,
> > how do I specify that?
> >
> > Regards,
> >
> > Minto van der Sluis
> > Software innovator / renovator
> > Xup BV
> >
>
Re: Query over multiple named graphs
Posted by Tommaso Teofili <to...@gmail.com>.
Hi Minto,
I think that you should use a union graph (UnionMGraph) over your
underlying named graphs and that should work as expected.
I hope this helps,
Tommaso
2013/1/6 Minto van der Sluis <mi...@xup.nl>
> Hi folks,
>
> Currently I am using clerezza with a Jena TDB storage backend to store
> multiple named graphs.
>
> Now I wonder how to perform a query over these named graphs. I can use
> the following command:
>
> TcManager.executeSparqlQuery( query, ? )
>
> But what should be used as the triple collection? If the default graph,
> how do I specify that?
>
> Regards,
>
> Minto van der Sluis
> Software innovator / renovator
> Xup BV
>