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.
Uh oh!
There was an error while loading. Please reload this page.
-
The respective use cases between
Store.addandStore.addNare 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
addmethod, whileSPARQLUpdateStoreor 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.pluginsuseaddrather 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 :
Storethat multiple uses ofStore.addshould be considered an exceptional case,Store.addNshould always be preferred. This makes it easier forStoreimplementers, 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.Storethat multiple uses ofStore.addcan be a valid use case, and thus encourageStoreimplementers to consider naive/straightforward implementations ofStore.addas a bug rather than a feature.Beta Was this translation helpful? Give feedback.
All reactions