Clarify respective use cases of Store.add
vs. Store.addN
, and correct use of Graph.parse
#1597
Replies: 3 comments
-
The idea is that addN should be semantically equivalent to repeat calls to add, but allow stores where transections matter to override and do a bulk add. I think the fact that Another problem is that each parser pretty much makes this decision itself, each call add in different ways. In the often talked about, long promised, but not really pending any time very soon, reworking of the parsers to allow streaming parsing would have one central |
Beta Was this translation helpful? Give feedback.
-
As an active user of RDFLib, I don't see that there's much "clarification" needed. The choice between Batching |
Beta Was this translation helpful? Give feedback.
-
Well, not when they are using
That's a great idea :)
So I thought, but that turns out to be unfortunate. |
Beta Was this translation helpful? Give feedback.
-
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.Beta Was this translation helpful? Give feedback.
All reactions