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

Feat: implement new command EXZSCAN and fix compile warnings. #7

Merged
merged 2 commits into from
Jun 24, 2022
Merged

Feat: implement new command EXZSCAN and fix compile warnings. #7

merged 2 commits into from
Jun 24, 2022

Conversation

RinChanNOWWW
Copy link
Contributor

Signed-off-by: RinChanNOWWW hzy427@gmail.com

Summary

related issues: #4

Implementation reference: Redis 5.0 https://redis.io/commands/scan/

Command Description

EXZSCAN

EXZSCAN key cursor [MATCH pattern] [COUNT count]
time complexity: O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.

Command Description:

Iterates elements of TairZset types and their associated scores.

EXSCAN is a cursor based iterator. This means that at every call of the command, the server returns an updated cursor that the user needs to use as the cursor argument in the next call. An iteration starts when the cursor is set to 0, and terminates when the cursor returned by the server is 0.

While EXSCAN does not provide guarantees about the number of elements returned at every iteration, it is possible to empirically adjust the behavior of EXZSCAN using the COUNT option. Basically with COUNT the user specified the amount of work that should be done at every call in order to retrieve elements from the collection. This is just a hint for the implementation, however generally speaking this is what you could expect most of the times from the implementation.

It is possible to only iterate elements matching a given glob-style pattern, similarly to the behavior of the KEYS command that takes a pattern as only argument. To do so, just append the MATCH arguments at the end of the EXZSCAN command. It is important to note that the MATCH filter is applied after elements are retrieved from the collection, just before returning data to the client. This means that if the pattern matches very little elements inside the collection, EXZSCAN will likely return no elements in most iterations.

More detail information: https://redis.io/commands/scan/

Return value

A two elements multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements.

Others

  • Fix the compile warnings.
  • Add a new data structure list (double linked list) from Redis source codes.

Signed-off-by: RinChanNOWWW <hzy427@gmail.com>
Copy link
Collaborator

@chenyang8094 chenyang8094 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/tairzset.c Outdated Show resolved Hide resolved
src/tairzset.c Outdated Show resolved Hide resolved
src/tairzset.c Outdated Show resolved Hide resolved
@chenyang8094 chenyang8094 added the to-be-merged to be merged label Jun 23, 2022
Signed-off-by: RinChanNOWWW <hzy427@gmail.com>
@chenyang8094 chenyang8094 merged commit e29845d into tair-opensource:master Jun 24, 2022
@RinChanNOWWW RinChanNOWWW deleted the FEAT-EXZSCAN branch June 24, 2022 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-be-merged to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants