Closed ronag closed 2 years ago
Is there a way to fix this? Either in the abstract base class or modifying the tests?
I would advise against that pattern. Going from a private API to a public API means double encoding, massaging of options, deferred open, etc. This will hurt performance and API consistency. The two forms of batch()
also have different performance characteristics; combining them makes it difficult for a consumer to predict what's best for them.
Do you have any benchmarks on the two forms of batch for e.g. leveldb? Just curious.
I don't have benchmarks. Personally I prefer batch(ops)
because the array of operations is easier to integrate with other code. Chained batch could be useful when you're writing a big batch and want to avoid blocking the main thread on the copying of that data - but I've never had that problem.
Would it maybe make sense then to implement chained batch in terms of batch(ops) by default?
It already does.
I would expect to be able to implement
batch(ops)
in terms of a chained batch. However, that is not possible given the combination of abstract chained batch and the tests, i.e.Will fail two tests: