You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Chris Clarke <cc...@talis.com> on 2011/10/13 14:52:59 UTC

Named graphs Fuseki/TDB

I'm trying to load some data into named graphs in TDB and then query back with Fuseki. Perhaps I am doing something ridiculously stupid here having never worked with quads and named graphs before....

For my test case I have about 5 million quads I am trying to load into one named graph, here is a sample of some:

<http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_8> <http://example.com/items/6226E191-0A32-F348-8F38-AABDBC73EE83>  <http://example.com/> .
<http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_9> <http://example.com/items/0FBFA283-11EB-1A04-1F68-F8B36E03F932>  <http://example.com/> .
<http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/vocab/resourcelist/schema#Section>  <http://example.com/> .
<http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>  <http://example.com/> .

What I would expect is that each of these quads get loaded into a graph named <http://example.com/>

Using tdbloader2, I successfully loaded these into a fresh TDB database location.

Start Fuseki 0.2.1-snapshot using this manifest:

@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .

[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

 <#dataset> rdf:type      tdb:DatasetTDB ;
     tdb:location "/tmp/DBQ-test" ;
     .

I try and submit this test query via the Fueski web interface (http://myfusekiserver:3030/sparql.jsp):

select count(?s)
from named <http://example.com/>
where {?s ?p ?o}

Fuseki says:

Error 400: Query may not include a dataset description (FROM/FROM NAMED)


Fuseki - version 0.2.1-SNAPSHOT (Date: 2011-09-08T16:38:26+0000)

Aside: I ran tdbstats on the location where I loaded the quads, I got the results I would expect in the stats.opt file:

(stats
  (meta
    (timestamp "2011-10-13T10:22:47.351+00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
    (run@ "2011/10/13 10:22:47 UTC")
    (count 5669532))
  (<http://purl.org/vocab/resourcelist/schema#created> 5037)
  (<http://purl.org/vocab/resourcelist/schema#uri> 21071)
  (<http://lists.talis.com/schema/appConfig#feedbackFunction> 1)
  (<http://purl.org/dc/terms/created> 144982)
....

Thus I would assume my TDB dataset has the correct data in it... Perhaps my manifest file is not correct?

Thanks,

Chris


Re: Named graphs Fuseki/TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi Chris

Chris Clarke wrote:
> I'm trying to load some data into named graphs in TDB and then query back with Fuseki. Perhaps I am doing something ridiculously stupid here having never worked with quads and named graphs before....
> 
> For my test case I have about 5 million quads I am trying to load into one named graph, here is a sample of some:
> 
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_8> <http://example.com/items/6226E191-0A32-F348-8F38-AABDBC73EE83>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_9> <http://example.com/items/0FBFA283-11EB-1A04-1F68-F8B36E03F932>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/vocab/resourcelist/schema#Section>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>  <http://example.com/> .
> 
> What I would expect is that each of these quads get loaded into a graph named <http://example.com/>
> 
> Using tdbloader2, I successfully loaded these into a fresh TDB database location.
> 
> Start Fuseki 0.2.1-snapshot using this manifest:
> 
> @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
> 
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> 
>  <#dataset> rdf:type      tdb:DatasetTDB ;
>      tdb:location "/tmp/DBQ-test" ;
>      .
> 
> I try and submit this test query via the Fueski web interface (http://myfusekiserver:3030/sparql.jsp):

By the way, I often use curl or s-query to send queries to Fuseki,
it's easier to cut & paste into emails and send to others:

s-query --service=http://127.0.0.1:3030/ds/sparql "SELECT COUNT(?s) { GRAPH <http://example.com/> { ?s ?p ?o } }"

s-query is available in Fuseki.
It's Ruby! ;-)
Documented here: http://openjena.org/wiki/SOH

Kudos to Andy.

Paolo

> 
> select count(?s)
> from named <http://example.com/>
> where {?s ?p ?o}
> 
> Fuseki says:
> 
> Error 400: Query may not include a dataset description (FROM/FROM NAMED)
> 
> 
> Fuseki - version 0.2.1-SNAPSHOT (Date: 2011-09-08T16:38:26+0000)
> 
> Aside: I ran tdbstats on the location where I loaded the quads, I got the results I would expect in the stats.opt file:
> 
> (stats
>   (meta
>     (timestamp "2011-10-13T10:22:47.351+00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
>     (run@ "2011/10/13 10:22:47 UTC")
>     (count 5669532))
>   (<http://purl.org/vocab/resourcelist/schema#created> 5037)
>   (<http://purl.org/vocab/resourcelist/schema#uri> 21071)
>   (<http://lists.talis.com/schema/appConfig#feedbackFunction> 1)
>   (<http://purl.org/dc/terms/created> 144982)
> ....
> 
> Thus I would assume my TDB dataset has the correct data in it... Perhaps my manifest file is not correct?
> 
> Thanks,
> 
> Chris
> 
> 

Re: Named graphs Fuseki/TDB

Posted by Andy Seaborne <an...@apache.org>.
On 13/10/11 20:10, Andy Seaborne wrote:
>
> Fuseki currently does pass through the FROM/FROM NAMED.

... does not pass through ...

	Andy

(That's what you get rushing to send an email from the train when you 
know there's a tunnel soon)

Re: Named graphs Fuseki/TDB

Posted by Andy Seaborne <an...@apache.org>.
On 13/10/11 14:01, Paolo Castagna wrote:
> Hi Chris
>
> Chris Clarke wrote:
>> I'm trying to load some data into named graphs in TDB and then query back with Fuseki. Perhaps I am doing something ridiculously stupid here having never worked with quads and named graphs before....
>>
>> For my test case I have about 5 million quads I am trying to load into one named graph, here is a sample of some:
>>
>> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#_8>  <http://example.com/items/6226E191-0A32-F348-8F38-AABDBC73EE83>   <http://example.com/>  .
>> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#_9>  <http://example.com/items/0FBFA283-11EB-1A04-1F68-F8B36E03F932>   <http://example.com/>  .
>> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://purl.org/vocab/resourcelist/schema#Section>   <http://example.com/>  .
>> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>   <http://example.com/>  .
>>
>> What I would expect is that each of these quads get loaded into a graph named<http://example.com/>
>>
>> Using tdbloader2, I successfully loaded these into a fresh TDB database location.
>>
>> Start Fuseki 0.2.1-snapshot using this manifest:
>>
>> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#>  .
>> @prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>  .
>> @prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>  .
>> @prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#>  .
>> @prefix tdb:<http://jena.hpl.hp.com/2008/tdb#>  .
>>
>> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>>
>>   <#dataset>  rdf:type      tdb:DatasetTDB ;
>>       tdb:location "/tmp/DBQ-test" ;
>>       .
>>
>> I try and submit this test query via the Fueski web interface (http://myfusekiserver:3030/sparql.jsp):
>>
>> select count(?s)
>> from named<http://example.com/>
>> where {?s ?p ?o}
>>
>> Fuseki says:
>>
>> Error 400: Query may not include a dataset description (FROM/FROM NAMED)
>
> We have recently seen Tim asking a similar question (with a similar error).
> This is the relevant thread: http://markmail.org/message/igbs7uxlx5xtooyz
>
> As a work around, you could use this as an alternative:
>
> SELECT COUNT(?s)
> {
>    GRAPH<http://example.com/
>    {
>      ?s ?p ?o
>    }
> }
>
> Does this work for you?

It's not a workaround.  That's how, in SPARQL, you access a named graph.

The email referred to above is about changing the dataset the query runs 
over to a subset of the graphs in the store.  See the TDB wiki about 
dynamic datasets.
http://www.openjena.org/wiki/TDB/DynamicDatasets

Using GRAPH is better for access to a specific graph.  Only if you want to
1/ Have a default graph that is the union of a set of other graphs
2/ restrict the visible named graphs

do you need FROM/FROM NAMED with TDB. It's a specialized use.

Fuseki currently does pass through the FROM/FROM NAMED.

	Andy

>
>>
>>
>> Fuseki - version 0.2.1-SNAPSHOT (Date: 2011-09-08T16:38:26+0000)
>>
>> Aside: I ran tdbstats on the location where I loaded the quads, I got the results I would expect in the stats.opt file:
>>
>> (stats
>>    (meta
>>      (timestamp "2011-10-13T10:22:47.351+00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
>>      (run@ "2011/10/13 10:22:47 UTC")
>>      (count 5669532))
>>    (<http://purl.org/vocab/resourcelist/schema#created>  5037)
>>    (<http://purl.org/vocab/resourcelist/schema#uri>  21071)
>>    (<http://lists.talis.com/schema/appConfig#feedbackFunction>  1)
>>    (<http://purl.org/dc/terms/created>  144982)
>> ....
>>
>> Thus I would assume my TDB dataset has the correct data in it... Perhaps my manifest file is not correct?
>
> I don't think that is the problem.
>
> Paolo
>
>>
>> Thanks,
>>
>> Chris
>>
>>


Re: Named graphs Fuseki/TDB

Posted by Paolo Castagna <ca...@googlemail.com>.
Hi Chris

Chris Clarke wrote:
> I'm trying to load some data into named graphs in TDB and then query back with Fuseki. Perhaps I am doing something ridiculously stupid here having never worked with quads and named graphs before....
> 
> For my test case I have about 5 million quads I am trying to load into one named graph, here is a sample of some:
> 
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_8> <http://example.com/items/6226E191-0A32-F348-8F38-AABDBC73EE83>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_9> <http://example.com/items/0FBFA283-11EB-1A04-1F68-F8B36E03F932>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/vocab/resourcelist/schema#Section>  <http://example.com/> .
> <http://example.com/sections/FFF9AF7F-54DF-53A5-E2A1-E08F4F7C270F> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>  <http://example.com/> .
> 
> What I would expect is that each of these quads get loaded into a graph named <http://example.com/>
> 
> Using tdbloader2, I successfully loaded these into a fresh TDB database location.
> 
> Start Fuseki 0.2.1-snapshot using this manifest:
> 
> @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
> 
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> 
>  <#dataset> rdf:type      tdb:DatasetTDB ;
>      tdb:location "/tmp/DBQ-test" ;
>      .
> 
> I try and submit this test query via the Fueski web interface (http://myfusekiserver:3030/sparql.jsp):
> 
> select count(?s)
> from named <http://example.com/>
> where {?s ?p ?o}
> 
> Fuseki says:
> 
> Error 400: Query may not include a dataset description (FROM/FROM NAMED)

We have recently seen Tim asking a similar question (with a similar error).
This is the relevant thread: http://markmail.org/message/igbs7uxlx5xtooyz

As a work around, you could use this as an alternative:

SELECT COUNT(?s)
{
  GRAPH <http://example.com/
  {
    ?s ?p ?o
  }
}

Does this work for you?

> 
> 
> Fuseki - version 0.2.1-SNAPSHOT (Date: 2011-09-08T16:38:26+0000)
> 
> Aside: I ran tdbstats on the location where I loaded the quads, I got the results I would expect in the stats.opt file:
> 
> (stats
>   (meta
>     (timestamp "2011-10-13T10:22:47.351+00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
>     (run@ "2011/10/13 10:22:47 UTC")
>     (count 5669532))
>   (<http://purl.org/vocab/resourcelist/schema#created> 5037)
>   (<http://purl.org/vocab/resourcelist/schema#uri> 21071)
>   (<http://lists.talis.com/schema/appConfig#feedbackFunction> 1)
>   (<http://purl.org/dc/terms/created> 144982)
> ....
> 
> Thus I would assume my TDB dataset has the correct data in it... Perhaps my manifest file is not correct?

I don't think that is the problem.

Paolo

> 
> Thanks,
> 
> Chris
> 
>