Skip to content

Instantly share code, notes, and snippets.

@bad
Created January 5, 2011 20:28
Show Gist options
  • Save bad/766954 to your computer and use it in GitHub Desktop.
Save bad/766954 to your computer and use it in GitHub Desktop.
demonstrates a discrepancy between RDF::Query#each_solution and RDF::Query#solutions.each
require 'rubygems'
require 'rdf'
require 'rdf/rdfxml'
require 'sparql/client'
lmdb = SPARQL::Client::Repository.new 'http://data.linkedmdb.org/sparql'
query = lmdb.client.
select(:movie).
prefix('movie: <http://data.linkedmdb.org/resource/movie/>').
where(
[:actor, RDF::URI.new('http://data.linkedmdb.org/resource/movie/actor_name'), 'Peter O\'Toole'],
[:movie, RDF::URI.new('http://data.linkedmdb.org/resource/movie/actor'), :actor]
)
solutions = 0
query.each_solution { |s| solutions+=1 }
puts "each_solutions #{solutions} vs. solutions.each #{query.solutions.size}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment