This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Clarify respective use cases of Store.add
vs. Store.addN
, and correct use of Graph.parse
#357
Labels
Milestone
The respective use cases between
Store.add
andStore.addN
are not really clear. More precisely, when some one has several triples to write to a store (not necessarily many, nor necessarily available as an iterable), is itStore.add
, orStore.addN
?This needs clarification because currently the answer is "it depends on the store"; more precisely "IOMemory" and "Sleepycat" answer (a), as they have a rather efficient
add
method, whileSPARQLUpdateStore
or the SqlAlchemy plugin answer (b), since they make a single query to the underlying store for each call toadd
.There is a rather serious consequence to this lack of clarity, in the use of
Graph.parse
. All parsers inrdflib.plugins
useadd
rather thanaddN
. As a consequence, it might be very inefficient to write:depending on the underlying store of
g
. For "add-inefficient" stores, one has to write:This breaks object encapsulation, which is bad.
I see two solutions :
Store
that multiple uses ofStore.add
should be considered an exceptional case,Store.addN
should always be preferred. This makes it easier forStore
implementers, but harder for programmers using stores (as they have to handle the "buffering" of triples). In particular, this requires to fix all the parser implementation to comply with this.Store
that multiple uses ofStore.add
can be a valid use case, and thus encourageStore
implementers to consider naive/straightforward implementations ofStore.add
as a bug rather than a feature.The text was updated successfully, but these errors were encountered: