spacejam / sled

the champagne of beta embedded databases
Apache License 2.0
8.18k stars 383 forks source link

Lazy batch operations #1438

Open segeljakt opened 1 year ago

segeljakt commented 1 year ago

Use Case:

The Db::apply_batch requires all arguments to be materialized into a batch before writing them to sled. This potentially means I need to duplicate and serialize all my data before I can begin inserting it.

Proposed Change:

It would be nice if I could pass a lazy iterator to sled that contains the operations. Personally, I am only interested in insertions.

Who Benefits From The Change(s)?

Anyone who needs to perform big atomic batch updates. For example, persisting all entries in a local hashmap.

Alternative Approaches

Calling Db::insert per key-value pair, though this is not atomic.