-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RDF::Graph should use Repository#insert_statements #220
Comments
I think the way to do this may be to redirect to Repository#insert_statements and update each statement's graph_name using map or in an enumerator, depending on the form of statements. Note that insert_statements has a special case if the first element is an Enumerable. |
I came up with: def insert_statements(statements)
enum = statements.respond_to?(:each_statement) ? statements.each_statement : statements
@data.insert(*enum.map { |st| statement = st.dup; statement.graph_name = graph_name; statement })
end But planning to dig around a little more to make sure that's the best plan. |
There was a recent change to make sure that it could take an enumerator, as the I was thinking of something like the following: def insert_statements(statements)
enum = Enumerable::Enumerator.new do |yielder|
this.send(statements.respond_to?(:each_statement) ? :each_statement : :each) do |st|
st = st.dup
st.graph_name = graph_name;
yielder << st
end
end
@data.insert_statements(enum)
end This allows |
Graph previously avoided the multi-statement insert interfaces of its underlying `Repository`. By adding `#insert_statements`, we can use that interface, saving round-trips to external repositories. Closes #220.
RDF::Graph
relies onWritable#insert_statements
, which always inserts statements individually.Some (hopefully all)
Repository
implementations that interact with upstream data implement#insert_statements
as a single request. UsingGraph
to interact with a repository results in sending individual requests, regardless of theRepository
implementation.e.g., the following results in
some_statements.count
individual requests tosome_repository
:I'm working on a fix for this.
The text was updated successfully, but these errors were encountered: