[redland-dev] slow model creation with ruby bindings

carmen _ at whats-your.name
Tue Sep 7 23:10:28 CEST 2010


>slower to add new nodes to a root node triples that have the new nodes as subject.


is your entire graph contained in blank nodes hanging off a single subject? a pathological case that could be slow in any framework, (rebalancing, node-finding, isomorphism checks, yadda. see  http://blog.datagraph.org/2010/03/rdf-isomorphism )

> I just want my triples printed out

simplesy way is #yield parse_as_stream.(example http://gitorious.org/element/element/blobs/master/ruby/W/rdf.rb#line40 and theres gem using FFI rather than SWIG (possibly faster, possibly not) http://rdf.rubyforge.org/raptor/)




to print pass triple-yield a function: 

eg resourcename.raptor{|s,p,o|
 puts"s "+s.class.to_s+" "+s.to_s+"\n"+
     "p "+p.class.to_s+" "+p.to_s+"\n"+
     "o "+o.class.to_s+" "+o.to_s}



almost surely faster using a JSON model w/o SWIG sitting between: 


  def fromStream m,*i
    send(*i) do |s,p,o|
      m[s] ||= {'uri'=>s}
      m[s][p] ||= []
      m[s][p].push o
    end; m
  end


model={}

(E 'somefile.rdf').fromStream m, :redland

(  i rarely use blank nodes, but when i do theyre just JSON objects in the literal position of a statement without a 'uri' field..)


for just parsing, Raptor is extremely fast, perhaps the fastest...


More information about the redland-dev mailing list