Skip to content
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

Support multiple keys in dissoc #26

Open
purrgrammer opened this issue Aug 30, 2019 · 1 comment
Open

Support multiple keys in dissoc #26

purrgrammer opened this issue Aug 30, 2019 · 1 comment

Comments

@purrgrammer
Copy link

The key-value protocol's dissoc method supports removing one key at a time. Clojure's dissoc supports removing several keys at once:

(dissoc {:a 1 :b 2 :c 3} :c :b)
;;=> {:a 1}

Would it make sense for dissoc in Konserve to accept multiple keys as well?

Note that deletions of multiple keys could be batched for a performance gain in the underlying backend implementations. This is a breaking API change so I figured out I should I ask before submitting a patch.

I've also noticed that due to the insertion being based on assoc-in there is no way to perform batched updates. We could also consider adding a variant of assoc-in (or assoc) that allows for batched inserts, which projects like Datahike could ultimately benefit from.

@whilo
Copy link
Member

whilo commented Aug 31, 2019

That sounds reasonable to me. How would you do the batching? It would be a breaking change if the channel would close before the IO operations have succeeded. Operations can run in parallel as long as:

  1. Any arising error propagates as a value in the resulting channel.
  2. The whole operation does not succeed before all batched operations have succeeded.

Note that the user of the konserve API can still decide not to wait for the channel to close. Writing a patch with a bit of core.async foo, e.g. mapping over all keys to create channels and then go-looping over the lazy seq of channels to aggregate the result (any error), should do the trick I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants