Giter Site home page Giter Site logo

rdf-sesame's Introduction

Sesame 2.0 Adapter for RDF.rb

This is an RDF.rb plugin that adds support for Sesame 2.0-compatible RDF repositories accessed using Sesame's HTTP API.

Documentation

  • {RDF::Sesame}
    • {RDF::Sesame::Connection}
    • {RDF::Sesame::Server}
    • {RDF::Sesame::Repository}

This adapter implements the RDF::Repository interface; refer to the relevant RDF.rb API documentation for further usage instructions.

Limitations

  • This adapter does not contain any SPARQL support. To use a Sesame endpoint with SPARQL, see the SPARQL::Client gem.
  • This adapter is not yet optimized for RDF.rb 0.2.x's bulk-operation APIs, meaning that statement insertions and deletions are currently performed one by one; this may affect the performance of loading large datasets into Sesame. This will be addressed in an upcoming version.
  • This adapter is not yet optimized for RDF.rb 0.2.x's enhanced query APIs; this may adversely affect triple pattern query performance. This will be addressed in an upcoming version.

Caveats

  • Sesame rewrites blank node identifiers on inserted statements. For example, if you supply a _:foobar identifier, it becomes something like _:node156oo6equx12769 as soon as you insert it into a Sesame repository. This means that you can't construct and insert a statement containing a blank node term and then expect to successfully be able check for its existence using the Repository#has_statement? method. This is also the reason that 7 specs for RDF::Repository currently fail with this adapter.

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release of the RDF::Sesame gem, do:

% [sudo] gem install rdf-sesame

Download

To get a local working copy of the development repository, do:

% git clone git://github.com/ruby-rdf/rdf-sesame.git

Alternatively, download the latest development version as a tarball as follows:

% wget https://github.com/ruby-rdf/rdf-sesame/tarball/master

Tests

In order to run test, you should use dotenv (which is set as a development dependency) and have a .env file with the following environment variables:

SESAME_URL=http://localhost:8080/openrdf-sesame # has to be an accessible openrdf-sesame server
SESAME_REPOSITORY=integration_test # has to be the name of an existing repository on which we'll be doing the integration tests.

You can then run them with:

% bundle exec dotenv rake spec

Mailing List

Author

Contributors

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying {file:UNLICENSE} file.

rdf-sesame's People

Contributors

abrisse avatar artob avatar berezovskyi avatar danny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rdf-sesame's Issues

Optimize triple pattern queries

This adapter is not yet optimized for RDF.rb 0.2.x's enhanced query APIs; this may adversely affect triple pattern query performance.

This should be addressed in an upcoming version.

Bug inserting RDF-XML based graphs or reader into repositories

Bug inserting RDF-XML based graphs into repositories.

I am able to insert NTriple based readers into a Sesame repository. However, RDFXML ones cannot be inserted. Here's what I've been trying:
require 'rdf'
require 'rdf/sesame'
require 'rdf/rdfxml'
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')

Successfully returns count of 47

reader = RDF::NTriples::Reader.new(File.read(RAILS_ROOT + '/public/doap.nt'))
repository.clear
repository.insert(reader)
repository.count

Only returns count of 3

reader = RDF::RDFXML::Reader.new(File.read(RAILS_ROOT + '/public/doap.xml'))
repository = RDF::Sesame::Repository.new('http://localhost:8080/openrdf-sesame/repositories/test')
repository.clear
repository.insert(reader)
repository.count

Graph count returns 47, but insertion into repository fails

stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
puts graph.count

Now that we have a graph, insert into repository

This inserts 3 entries, but not the entire 47

repository.clear
repository.insert(graph.to_a)
repository.count

Same thing, returns 3

repository.clear
repository.insert(*graph.to_a)
repository.count

Same thing, returns 3

repository.clear
repository<<graph.to_rdf
repository.count

The << method in writable.rb looks like it detects a graph and then

calls insert_graph, but none of these seem to work either

repository<<graph
repository.insert(graph)
repository.insert(graph.to_ntriples)
repository.insert(_graph.to_ntriples)
graph.each { |s| repository << s }
graph.each { |s| repository.insert(_s) }
graph.each { |s| repository.insert(s) }

stream = File.open(RAILS_ROOT + '/public/doap.xml')
graph = RDF::Graph.new
RDF::RDFXML::Reader.new(stream).each { |s| graph << s }
reader = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(reader)

I am able to get this to work with the RDF Context gem:
require 'rdf'
require 'rdf/sesame'
require 'rdf_context'
url = "http://localhost:8080/openrdf-sesame/repositories/test"
repository = RDF::Sesame::Repository.new(url)

The doap.xml file fails but rdf.xml does get parsed correctly

f = File.open(RAILS_ROOT + '/public/rdf.xml')
graph = RdfContext::Graph.new
graph.parse(f.read, nil, :type => :rdfxml)

statements = RDF::NTriples::Reader.new(graph.to_ntriples)
repository.insert(*statements)
repository.count
repository.clear!

Deleting statements in a context

With the RDF::Repository, I can set a context with the #set_context method. After than, every statement I'm going to insert into the repository will be assigned this context.

But when I delete statements from the repository, the context that is used to delete the statements is the one already assigned to the statement (RDF::Statement#context= or #graph=). So the two operations are not symmetric at all.

I'm going to do a PR in a few to adjust that behavior.

Implement support for persistent HTTP connections

Currently, connections are internally implemented using Net::HTTP from Ruby's standard library, and connections are always transient, i.e. they do not persist from one request to the next and must always be reopened when used.

We should implement support for persistent Keep-Alive connections as a future improvement.

Optimize bulk operations

This adapter is not yet optimized for RDF.rb 0.2.x's bulk-operation APIs, meaning that statement insertions and deletions are currently performed one by one; this may affect the performance of loading large datasets into Sesame.

This should be addressed in an upcoming version.

Infinite loop when accessing statements or graphs of a Sesame repository.

I can't get the contexts used inside a Sesame repository anymore. It loops infinitely until the stack level is too deep and it raises an error. It does the same when I try to list the statements using '#each_statement".

The code to trigger this behavior is pretty simple:

server = RDF::Sesame::Server.new(db_url)
repository = server.repository(repository_name')

# either this
repository.each_statement do |s| # <= each starts the infinite loop 
  puts s.inspect
end

# or this
puts repository.graph_names.inspect

I'm pushing a PR in a few minutes, I'll reference this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.