Created
December 5, 2010 15:40
-
-
Save bad/729180 to your computer and use it in GitHub Desktop.
test case demonstrating that Spira w/SPARQL::Client repository makes excessive CONSTRUCT queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ruby-debug' | |
require 'spira' | |
require 'rdf/rdfxml' | |
require 'sparql/client' | |
class Actor | |
include Spira::Resource | |
base_uri 'http://data.linkedmdb.org/resource/actor/' | |
type URI.new 'http://data.linkedmdb.org/resource/movie/actor' | |
default_vocabulary URI.new('http://data.linkedmdb.org/resource/movie/') | |
property :actor_id, :type => Integer | |
property :actor_name, :type => String | |
property :label, :predicate => RDFS.label, :type => String | |
property :page, :predicate => FOAF.page, :type => URI | |
has_many :performance, :type => URI | |
end | |
lmdb = SPARQL::Client::Repository.new 'http://data.linkedmdb.org/sparql' | |
Spira.add_repository! :default, lmdb | |
Debugger.start | |
Debugger.add_breakpoint('SPARQL::Client', 'query') | |
#Debugger.add_breakpoint('SPARQL::Client', 'get') | |
js = Actor.for(9) | |
# | |
# this will call SPARQL::Client#query twice for each property with a | |
# CONSTRUCT query | |
# | |
puts js.actor_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- lib/sparql/client.rb.orig 2010-10-19 14:35:53.000000000 +0000 | |
+++ lib/sparql/client.rb 2010-10-19 14:42:59.000000000 +0000 | |
@@ -28,7 +28,8 @@ | |
# @param [Hash{Symbol => Object}] options | |
def initialize(url, options = {}, &block) | |
@url, @options = RDF::URI.new(url.to_s), options | |
- @headers = {'Accept' => "#{RESULT_JSON}, #{RESULT_XML}, text/plain"} | |
+ @headers = {'Accept' => [RESULT_JSON, RESULT_XML, | |
+ RDF::Format.content_types.collect { |k,v| k.to_s }].join(', ')} | |
if block_given? | |
case block.arity | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment