- From: Ben Lavender <blavender@gmail.com>
- Date: Sun, 10 Oct 2010 13:26:52 -0400
- To: Christoph Badura <bad@bsd.de>
- Cc: public-rdf-ruby@w3.org
Going over this initially, I'm not sure why it would be happening. #empty? is being called on a query result set, not the repository. Unfortunately, I'm traveling for work and don't have a local SPARQL endpoint to test with. I'll figure something out tomorrow and try and get you a response as soon as possible, since, well, yeah, this is a pretty huge problem. Not that it means the current example is not a bug, but note that the SPARQL repository is more of an example/base, since SPARQL varies from implementation to implementation. ARQ, for example, includes a non-standard count function, which prevents the default iterate-and-count implementation. It's probably not a big deal to create an ARQ SPARQL repository class that has support for that, and I'd help you work on that if you wanted. Ben On Sat, Oct 9, 2010 at 10:55 AM, Christoph Badura <bad@bsd.de> wrote: > I'm trying to use SPARQL::Client as a Repository for Spira. > > require 'spira' > require 'sparql/client' > > class Foo > include Spira::Resource > > property :whatever, :predicate => DC.whatever > end > > repo = SPARQL::Client::Repository.new 'http://localhost:2020/sparql' > Spira.add_repository! :default, repo > > foo = Foo.for(RDF::URI.new("http://example.com/foo/1")) > > As soon as I access the first property, the sparql server (i'm using joseki) > is reporting the first query: > > INFO SPARQL :: Query: CONSTRUCT { ?s ?p ?o . } WHERE { ?s ?p ?o . } > > Returning all the triples in the graph will take a while for any real world > repository. The test data I have loaded is some 40MB. > > The reason for this are the "unless stamtements.empty?" modifiers used in > #reload_attributes. Countable#empty? relies on #each and SPARQL::Client:: > Repository#each does > client.construct([:s, :p, :o]).where([:s, :p, :o]).each_statement(&block) > > I haven't come up with a useful test case, so I'm posting here instead. > > Here's relevant info from the stacktraces: > > (rdb:1) l > [8, 17] in /usr/pkg/lib/ruby/gems/1.8/gems/rdf-0.2.3/lib/rdf/mixin/countable.rb > 8 # Returns `true` if `self` contains no RDF statements. > 9 # > 10 # @return [Boolean] > 11 def empty? > 12 empty = true > => 13 each { empty = false; break } > 14 empty > 15 end > 16 > 17 ## > (rdb:1) up > #4 /usr/pkg/lib/ruby/gems/1.8/gems/spira-0.0.8/lib/spira/resource/instance_methods.rb:87:in `reload_attributes' > (rdb:1) where > #1 /usr/pkg/lib/ruby/gems/1.8/gems/sparql-client-0.0.5/lib/sparql/client/repository.rb:26:in `each' > #2 /usr/pkg/lib/ruby/gems/1.8/gems/rdf-0.2.3/lib/rdf/mixin/queryable.rb:67:in `query_pattern' > #3 /usr/pkg/lib/ruby/gems/1.8/gems/rdf-0.2.3/lib/rdf/mixin/countable.rb:13:in `empty?' > --> #4 /usr/pkg/lib/ruby/gems/1.8/gems/spira-0.0.8/lib/spira/resource/instance_methods.rb:87:in `reload_attributes' > #5 /usr/pkg/lib/ruby/gems/1.8/gems/spira-0.0.8/lib/spira/resource/instance_methods.rb:57:in `reload' > #6 /usr/pkg/lib/ruby/gems/1.8/gems/promise-0.3.0/lib/promise.rb:89:in `method_missing' > #7 /usr/pkg/lib/ruby/gems/1.8/gems/spira-0.0.8/lib/spira/resource/instance_methods.rb:323:in `attribute_get' > #8 /usr/pkg/lib/ruby/gems/1.8/gems/spira-0.0.8/lib/spira/resource/dsl.rb:254:in `identifier' > #9 test-sparql.rb:10 > (rdb:1) > down 3 > #1 /usr/pkg/lib/ruby/gems/1.8/gems/sparql-client-0.0.5/lib/sparql/client/repository.rb:26:in `each' > (rdb:1) l > [21, 30] in /usr/pkg/lib/ruby/gems/1.8/gems/sparql-client-0.0.5/lib/sparql/client/repository.rb > 21 # @yield [statement] > 22 # @yieldparam [RDF::Statement] statement > 23 # @return [Enumerator] > 24 # @see RDF::Repository#each > 25 def each(&block) > => 26 unless block_given? > 27 RDF::Enumerator.new(self, :each) > 28 else > 29 client.construct([:s, :p, :o]).where([:s, :p, :o]).each_statement(&block) > 30 end > (rdb:1) p block_given? > true > (rdb:1) > > --chris > >
Received on Sunday, 10 October 2010 21:11:02 UTC