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

Added support for including keyspace ends in the ranges #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

keijokapp
Copy link

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.

@keijokapp keijokapp force-pushed the subspace-ends branch 2 times, most recently from 7b793d8 to bf6f952 Compare July 1, 2024 18:48
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

Successfully merging this pull request may close these issues.

1 participant