I've implemented a concept solution for #78. I think this is the best option, ie least bloat for the maximum robustness. The implementation hasn't been tested and needs more documentation. I'm interested in any feedback.
The PR does the following:
Add StartsWith variants for all methods that deal with ranges. Those are what developers should use to get the prefix behavior. The original methods continue work as before by default.
Modify Subspace#packRange to deal with start/end combinations. Add Subspace#packRangeStartsWith for handling prefixes. Like before, the later is what developers should use for prefix behavior but the original one stays backwards compatible by default.
Make all packing/unpacking go through Subspace, so that there's only one central place for all that complexity. While packing/unpacking individual keys/values doesn't strictly need to go through subspace, there's now less reason to keep the transformer copies around. Maybe it should be a separate commit.
Add _noDefaultPrefix flag to subspace and Subspace#noDefaultPrefix and Database#noDefaultPrefix methods. These switch the subspace to a mode that enables including key space ends in the ranges. The naming of these could be improved.
Make end key default to subspace end in the noDefaultPrefix mode.
Make start key optional, defaulting to subspace start. This is good for consistency but also useful for abstractions that want to specify the range in an encoding agnostic way but still benefit from automatic key encoding/decoding and type safety.
I've implemented a concept solution for #78. I think this is the best option, ie least bloat for the maximum robustness. The implementation hasn't been tested and needs more documentation. I'm interested in any feedback.
The PR does the following:
StartsWith
variants for all methods that deal with ranges. Those are what developers should use to get the prefix behavior. The original methods continue work as before by default.Subspace#packRange
to deal withstart
/end
combinations. AddSubspace#packRangeStartsWith
for handling prefixes. Like before, the later is what developers should use for prefix behavior but the original one stays backwards compatible by default.Subspace
, so that there's only one central place for all that complexity. While packing/unpacking individual keys/values doesn't strictly need to go through subspace, there's now less reason to keep the transformer copies around. Maybe it should be a separate commit._noDefaultPrefix
flag to subspace andSubspace#noDefaultPrefix
andDatabase#noDefaultPrefix
methods. These switch the subspace to a mode that enables including key space ends in the ranges. The naming of these could be improved.noDefaultPrefix
mode.