Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
OpenAtomFoundation
pika
比较版本
7265daf25f21e4b426743d26d3f1f994b29f3bc2...59b119301ca4a0e31fb9e4991f7389fe52f6816a
pika
项目概览
镜像
/
OpenAtomFoundation
/
pika
10 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
pika
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
源分支
59b119301ca4a0e31fb9e4991f7389fe52f6816a
选择Git版本
...
目标分支
7265daf25f21e4b426743d26d3f1f994b29f3bc2
选择Git版本
比较
Commits (2)
https://gitcode.net/awesome-mirrors/OpenAtomFoundation/pika/-/commit/b4088b9b25af5a3868df6b2645aa1aad5f3de11e
chore:change `PLATFORM` field logic (#1615)
2023-06-14T11:08:37+08:00
baerwang
52104949+baerwang@users.noreply.github.com
https://gitcode.net/awesome-mirrors/OpenAtomFoundation/pika/-/commit/59b119301ca4a0e31fb9e4991f7389fe52f6816a
fix issue 1517: scan 命令不支持 type 参数 (#1582)
2023-06-14T20:25:24+08:00
ptbxzrt
89020404+ptbxzrt@users.noreply.github.com
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
10 deletion
+72
-10
build_docker.sh
build_docker.sh
+7
-8
include/pika_kv.h
include/pika_kv.h
+2
-0
src/pika_kv.cc
src/pika_kv.cc
+18
-2
tests/unit/scan.tcl
tests/unit/scan.tcl
+45
-0
未找到文件。
build_docker.sh
浏览文件 @
59b11930
...
...
@@ -56,24 +56,23 @@ then
TAG
=
"pikadb/pika:
$(
git describe
--tags
--abbrev
=
0
--always
)
"
fi
# if Platform is not set, set it "linux/amd64"
if
[
-z
"
$PLATFORM
"
]
then
PLATFORM
=
"linux/amd64"
fi
# if Platform is "all", set it "linux/amd64,linux/arm64,linux/arm"
if
[
"
$PLATFORM
"
=
"all"
]
then
PLATFORM
=
"linux/amd64,linux/arm,linux/arm64"
fi
# if Platform is not set, set it "linux/amd64"
if
[
-z
"
$PLATFORM
"
]
then
PLATFORM
=
"linux/amd64"
fi
# if proxy is set, set it
PROXY
=
false
if
[
-n
"
$proxy
"
]
then
PROXY
=
true
else
PROXY
=
false
fi
# check if docker is installed
...
...
include/pika_kv.h
浏览文件 @
59b11930
...
...
@@ -600,10 +600,12 @@ class ScanCmd : public Cmd {
int64_t
cursor_
=
0
;
std
::
string
pattern_
=
"*"
;
int64_t
count_
=
10
;
storage
::
DataType
type_
=
storage
::
DataType
::
kAll
;
void
DoInitial
()
override
;
void
Clear
()
override
{
pattern_
=
"*"
;
count_
=
10
;
type_
=
storage
::
DataType
::
kAll
;
}
};
...
...
src/pika_kv.cc
浏览文件 @
59b11930
...
...
@@ -1090,7 +1090,8 @@ void ScanCmd::DoInitial() {
while
(
index
<
argc
)
{
std
::
string
opt
=
argv_
[
index
];
if
((
strcasecmp
(
opt
.
data
(),
"match"
)
==
0
)
||
(
strcasecmp
(
opt
.
data
(),
"count"
)
==
0
))
{
if
((
strcasecmp
(
opt
.
data
(),
"match"
)
==
0
)
||
(
strcasecmp
(
opt
.
data
(),
"count"
)
==
0
)
||
(
strcasecmp
(
opt
.
data
(),
"type"
)
==
0
))
{
index
++
;
if
(
index
>=
argc
)
{
res_
.
SetRes
(
CmdRes
::
kSyntaxErr
);
...
...
@@ -1098,6 +1099,21 @@ void ScanCmd::DoInitial() {
}
if
(
strcasecmp
(
opt
.
data
(),
"match"
)
==
0
)
{
pattern_
=
argv_
[
index
];
}
else
if
(
strcasecmp
(
opt
.
data
(),
"type"
)
==
0
)
{
std
::
string
str_type
=
argv_
[
index
];
if
(
strcasecmp
(
str_type
.
data
(),
"string"
)
==
0
)
{
type_
=
storage
::
DataType
::
kStrings
;
}
else
if
(
strcasecmp
(
str_type
.
data
(),
"zset"
)
==
0
)
{
type_
=
storage
::
DataType
::
kZSets
;
}
else
if
(
strcasecmp
(
str_type
.
data
(),
"set"
)
==
0
)
{
type_
=
storage
::
DataType
::
kSets
;
}
else
if
(
strcasecmp
(
str_type
.
data
(),
"list"
)
==
0
)
{
type_
=
storage
::
DataType
::
kLists
;
}
else
if
(
strcasecmp
(
str_type
.
data
(),
"hash"
)
==
0
)
{
type_
=
storage
::
DataType
::
kHashes
;
}
else
{
res_
.
SetRes
(
CmdRes
::
kSyntaxErr
);
}
}
else
if
((
pstd
::
string2int
(
argv_
[
index
].
data
(),
argv_
[
index
].
size
(),
&
count_
)
==
0
)
||
count_
<=
0
)
{
res_
.
SetRes
(
CmdRes
::
kInvalidInt
);
return
;
...
...
@@ -1123,7 +1139,7 @@ void ScanCmd::Do(std::shared_ptr<Slot> slot) {
keys
.
clear
();
batch_count
=
left
<
PIKA_SCAN_STEP_LENGTH
?
left
:
PIKA_SCAN_STEP_LENGTH
;
left
=
left
>
PIKA_SCAN_STEP_LENGTH
?
left
-
PIKA_SCAN_STEP_LENGTH
:
0
;
cursor_ret
=
slot
->
db
()
->
Scan
(
storage
::
DataType
::
kAll
,
cursor_ret
,
pattern_
,
batch_count
,
&
keys
);
cursor_ret
=
slot
->
db
()
->
Scan
(
type_
,
cursor_ret
,
pattern_
,
batch_count
,
&
keys
);
for
(
const
auto
&
key
:
keys
)
{
RedisAppendLen
(
raw
,
key
.
size
(),
"$"
);
RedisAppendContent
(
raw
,
key
);
...
...
tests/unit/scan.tcl
浏览文件 @
59b11930
...
...
@@ -53,6 +53,51 @@ start_server {tags {"scan"}} {
assert_equal 100
[
llength $keys
]
}
test
"SCAN TYPE"
{
r flushdb
# populate only creates strings
r debug populate 1000
# Check non-strings are excluded
set cur 0
set keys
{}
while 1
{
set res
[
r scan $cur type
"list"
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
assert_equal 0
[
llength $keys
]
# Check strings are included
set cur 0
set keys
{}
while 1
{
set res
[
r scan $cur type
"string"
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
assert_equal 1000
[
llength $keys
]
# Check all three args work together
set cur 0
set keys
{}
while 1
{
set res
[
r scan $cur type
"string"
match
"key:*"
count 10
]
set cur
[
lindex $res 0
]
set k
[
lindex $res 1
]
lappend keys
{*}
$k
if
{
$cur
== 0
}
break
}
assert_equal 1000
[
llength $keys
]
}
foreach enc
{
intset hashtable
}
{
test
"SSCAN with encoding
$enc
"
{
# Create the Set
...
...