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

Add support to HSCAN. Fix #46 #47

Merged
merged 10 commits into from
Aug 29, 2019
Merged

Add support to HSCAN. Fix #46 #47

merged 10 commits into from
Aug 29, 2019

Conversation

hltbra
Copy link
Contributor

@hltbra hltbra commented Aug 29, 2019

This PR adds the new command HSCAN and fixes a bug with ZSCAN and start keys.

The size of the cursors was bumped to 8 * 1024 because 1024 was not a lot of cursors and 8x that isn't a lot of memory space.

A prefix is not the same thing as a starting point. The two
concepts were mixed before and it caused a bug where the sorted set
would not iterated correctly.

This commit includes a regression test.
Hashes with 512 or fewer entries will use a ziplist encoding by default, which changes
the behavior of HSCAN to return all entries, regardless of the COUNT parameter.
The same applies to sorted sets with 128 or fewer entries.

The `+ 100` is to avoid issues with `range()` & off-by-one errors (simpler than adding `+ 1` to the `range()` calls).
The empty string was a shortcut because it is a falsy value in Python, but it did not
express the right intentions and required a hack to work with plyvel (it does not
accept key_prefix and start arguments together).

This commit makes the intentions clear but requires some `None` checks.
This refactoring also makes it easier to add SCAN and SSCAN.
1024 cursors does not seem like a lot and 8x that is still a small number that should
fit in memory without too much overhead.
@hltbra hltbra merged commit d7f1a15 into master Aug 29, 2019
@hltbra hltbra deleted the feature/hscan branch August 29, 2019 16:40
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