-
-
Notifications
You must be signed in to change notification settings - Fork 53
Flag to disable iterator tests #345
Comments
It's hard to make a default implementation atomic. |
I know, that's why I said about leaving the atomic implementation up to the reader :-) Just only provide a "just enough" default one. |
IMO if the default can't be atomic, and therefor cannot pass the test suite (I don't remember if this is actually covered by the test suite), we shouldn't have a default. |
In that case, maybe a good alternative would be to add a flag to disable batch tests, so it's another way to say "this AbstractLevel doesn't support atomic batch operations", what do you think? Oh, and said that, maybe also this kind of informative test flags could be set as a metadata property of the AbstractLevel object itself that can be queried in runtime too, but this should be addresed better in a diferent issue :-) |
I'm not opposed to adding a flag per se (in addition to the ones we already have), but only if there's an If we were to add a default implementation of
Yeah, that's been on our todo list for some time now (Level/community#42). |
Not so much about non-atomic batch operations, BUT not suporting batch operations at all. Not sure how much important is support of batch operations vs doing them one after one, I find it more like a performance improvement than a basic feature...
Agree on that.
Great! :-D |
Oh I see. I do consider it a basic feature though. Writing multiple keys at once is a very common task in my experience. For convenience, performance, the atomicity of it (for example, to update indexes) and as a building block for writable streams. |
In addition, many modules in the ecosystem expect |
I see... Ok, my level is a wrapper one, so in that case, if there's a warranty that the underlying has atomic batch support, maybe I can be able to provide it myself on top of that, instead as a sucesion of operations... |
That is (or should be) safe to assume. |
If it helps, here's how |
Cool :-) Maybe could be good to add it to docs? Honestly, I though the batch support was optional... In that way, I though |
Sort of what I was thinking about to do, thanks :-) |
=> #346 |
Great, thank you :-) |
Are iterators a basic feature here too? Tests suite is failing me due to them now... What if it doesn't make sense or is not posible to iterate, like resources in a REST API where there's no list of all of them? |
Even more so. I'd say that iterators are Level's defining feature, that sets it apart from other key-value stores. |
🤦♂️ I just only wanted a key-value store... 😅 Ok, I'll try to implement it, I didn't want because I'm writing a SecureStore where keys are hashes, so no need to iterate over them. |
I have tried to implement iterators, and got to the conclusion it doesn't makes sense at all in my level. In it, you could be able to seek to a particular entry using its key and calculating its key hash the same way you would access with |
abstract-leveldown/abstract-leveldown.js
Lines 182 to 184 in 9d107d0
Default
_batch
implementation is a no-op, forcing you to implement it yourself to makeabstract-level/test
suite in your own AbstractLevel object. I think it would make sense to have a default implementation that just run over the given operations calling the object methods, something likeMain issue would be to add rollback support if one of the operations failed, but maybe this can be left as task for the reader since it's a more advanced and probably underlying backend dependent :-) Thoughs? Would you accept a pull-request for that?
The text was updated successfully, but these errors were encountered: