- From: carmen <_@whats-your.name>
- Date: Mon, 5 Apr 2010 09:15:58 +0000
- To: public-rdf-ruby@w3.org
- Cc: dave <dave@dajobe.org>
> PS. RDF::Raptor 0.2.0, released yesterday, included an initial set of > FFI bindings to Raptor, as well as RDF::Reader implementations based cool! my tools use tripleStreams :: URIString,URIString,(Resource URIString,Graph)|URIString so ive got unwrappers [1] and [2] parsing all the ttl files in git clone git://git.librdf.org/repositories/{bindings,librdf,raptor,rasqal}.git 3 runs: Benchmark.bm{|a| a.report{E('/').take.select{|e| e if e.ext=='ttl'}.map{|f| f.redland('turtle'){|s,p,o|nil}}}} user system total real 7.320000 0.040000 7.360000 ( 7.396536) 7.290000 0.040000 7.330000 ( 7.364663) 7.170000 0.030000 7.200000 ( 7.235484) Benchmark.bm{|a| a.report{E('/').take.select{|e| e if e.ext=='ttl'}.map{|f| f.raptor{|s,p,o|nil}}}} 8.660000 0.040000 8.700000 ( 8.791330) 8.600000 0.030000 8.630000 ( 8.634474) 8.530000 0.040000 8.570000 ( 8.671485) looking good.. worked out of the box too :) in order to get redland-bindings working (ruby 1.9.2dev) i did: add to bindings/ruby/redland_wrap.c: #define STR2CSTR(s) StringValuePtr(s) bindings/ruby default autohell failed, had to construct/run this: gcc -DHAVE_CONFIG_H -I. -DREDLAND_PRE_I -DREDLAND_TYPES_I -I/usr/include/rasqal -I -g -O2 -I/usr/include/rasqal -g -O2 -fPIC -DPIC -I/usr/include/ruby-1.9.1 -I/usr/include/ruby-1.9.1/ruby -I /usr/include/ruby-1.9.1/x86_64-linux/ -c redland_wrap.c -o redland_wrap.o bindings/ruby/lib/rdf/redland/: delete all explicit finalizer stuff in all .rb files (SWIG does this automagically now?) otherwise double-free errors right away. [1] def raptor ::RDF::Raptor::Turtle::Reader.open(d){|r|r.each_triple{|t| yield t[0].to_s, t[1].to_s, ((t[2].class==::RDF::Node||t[2].class==::RDF::URI) ? (E t[2].to_s) : t[2].value) }}; self end [2] def redland f e=->n{n.node_type=='NODE_TYPE_BLANK' ? n.to_s[1..-2] : n.uri.to_s} Redland::Parser.new(f,'').parse_as_stream(Redland::Uri.new(uri.match(/^(file|http)/) ? uri : 'file:'+d)){|s| yield e.(s.subject), e.(s.predicate), s.object.class==Redland::Literal ? s.object.do{|o| o.value.send ( E::XSDs[(dt=Redland.librdf_node_get_literal_value_datatype_uri o.node) && Redland.librdf_uri_to_string(dt) ]|| :to_s ) } : E(e.(s.object))} end
Received on Monday, 5 April 2010 09:16:56 UTC