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

support scan #225

Merged
merged 1 commit into from
Jul 19, 2024
Merged

support scan #225

merged 1 commit into from
Jul 19, 2024

Conversation

lhpqaq
Copy link
Contributor

@lhpqaq lhpqaq commented Jul 15, 2024

实现 #188
#199 已经几个月没更新了,所以我就实现了一下
支持在another Redis desktop manager 查看string类型,如果可以的话之后继续写hscan, sscan等。
辛苦大佬有时间指导一下 @HDT3213 🌹

实现细节:

  • 每次scan至少会迭代一个shard,否则返回的cursor与传入的cursor一致,会陷入循环
  • 如果本次scan已经迭代了一个shard,且当前shard+当前result > count,当前shard中的key会留到下一次scan返回,因为下次scan必须要迭代当前的shard。所以返回的数量可能<count,这样可以减少一些重复
  • 如果当前shard是本次scan迭代的第一个shard,且 当前shard > count, 那么返回的总结果会>count。

因为dict里没有import这些type,所以在database里对DictScan返回的结果再次判断type(存在type参数的情况下)。
对execType做了些修改,因为封装了getType,被execType和execScan调用。

test里测试了从cursor=0,到下一次cursor=0的情况。

@lhpqaq
Copy link
Contributor Author

lhpqaq commented Jul 15, 2024

没有看出check fail的原因,求提示

@lhpqaq lhpqaq force-pushed the pr_scan branch 2 times, most recently from f9fa4db to 8f9a635 Compare July 16, 2024 14:09
@HDT3213
Copy link
Owner

HDT3213 commented Jul 16, 2024

raft 不稳定而已, 我明天看一下你代码

@lhpqaq
Copy link
Contributor Author

lhpqaq commented Jul 16, 2024

@HDT3213 fail的test是TestLoadRDB,这个跟我添加的代码没有关系吧:
image

2024-07-16T14:20:56.3802436Z --- PASS: TestUndoRPopLPush (0.00s)
2024-07-16T14:20:56.3802831Z === RUN   TestLoadRDB
2024-07-16T14:20:56.3803618Z 2024/07/16 14:20:40 [ERROR][server.go:84] open rdb file failed open /home/runner/work/godis/godis/test.rdb: no such file or directory
2024-07-16T14:20:56.3804683Z     assert.go:39: expected bulk protocol, actually $-1
2024-07-16T14:20:56.3805477Z         , at /home/runner/work/godis/godis/database/persistence_test.go:26
2024-07-16T14:20:56.3806633Z     assert.go:31: expected 0, actually -2, at /home/runner/work/godis/godis/database/persistence_test.go:28
2024-07-16T14:20:56.3807663Z     assert.go:117: expected bulk protocol, actually *0
2024-07-16T14:20:56.3808436Z         , at /home/runner/work/godis/godis/database/persistence_test.go:30
2024-07-16T14:20:56.3809083Z     assert.go:117: expected bulk protocol, actually *0
2024-07-16T14:20:56.3810440Z         , at /home/runner/work/godis/godis/database/persistence_test.go:32
2024-07-16T14:20:56.3811145Z     assert.go:117: expected bulk protocol, actually *0
2024-07-16T14:20:56.3811851Z         , at /home/runner/work/godis/godis/database/persistence_test.go:34
2024-07-16T14:20:56.3812887Z     assert.go:20: expected 1, actually 0, at /home/runner/work/godis/godis/database/persistence_test.go:36
2024-07-16T14:20:56.3813637Z --- FAIL: TestLoadRDB (0.28s)
2024-07-16T14:20:56.3814530Z 2024/07/16 14:20:40 [ERROR][server.go:84] open rdb file failed open /home/runner/work/godis/godis/none/test.rdb: no such file or directory
2024-07-16T14:20:56.3815353Z === RUN   TestServerFsyncAlways
2024-07-16T14:20:56.3815823Z --- PASS: TestServerFsyncAlways (0.79s)

逻辑上好像也没什么关系。

@lhpqaq
Copy link
Contributor Author

lhpqaq commented Jul 16, 2024

raft 不稳定而已, 我明天看一下你代码

辛苦,刚刚给SimpleDict也添加了DictScan,仅仅是一次性返回所有key,不知道是否需要

@HDT3213
Copy link
Owner

HDT3213 commented Jul 16, 2024

没事没事,问题不大

@HDT3213 HDT3213 merged commit c1dd65d into HDT3213:master Jul 19, 2024
1 check failed
@HDT3213 HDT3213 mentioned this pull request Jul 19, 2024
@lhpqaq lhpqaq mentioned this pull request Jul 23, 2024
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.

2 participants