Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
a6534288
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6534288
编写于
5月 15, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-325: add unit test
上级
89e3ce2d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
19 deletion
+44
-19
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+5
-1
src/util/tests/skiplistTest.cpp
src/util/tests/skiplistTest.cpp
+39
-18
未找到文件。
src/util/src/tskiplist.c
浏览文件 @
a6534288
...
...
@@ -150,7 +150,11 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint8_t keyLen, ui
maxLevel
=
MAX_SKIP_LIST_LEVEL
;
}
pSkipList
->
keyInfo
=
(
SSkipListKeyInfo
){.
type
=
keyType
,
.
len
=
keyLen
,
.
dupKey
=
dupKey
,
.
freeNode
=
freeNode
};
pSkipList
->
keyInfo
.
type
=
keyType
;
pSkipList
->
keyInfo
.
len
=
keyLen
;
pSkipList
->
keyInfo
.
dupKey
=
dupKey
;
pSkipList
->
keyInfo
.
freeNode
=
freeNode
;
pSkipList
->
keyFn
=
fn
;
pSkipList
->
comparFn
=
getKeyComparFunc
(
keyType
);
pSkipList
->
maxLevel
=
maxLevel
;
...
...
src/util/tests/skiplistTest.cpp
浏览文件 @
a6534288
...
...
@@ -281,34 +281,55 @@ void skiplistPerformanceTest() {
// todo not support duplicated key yet
void
duplicatedKeyTest
()
{
#if 0
SSkipListKey key;
key.nType = TSDB_DATA_TYPE_INT;
SSkipListNode **pNodes = NULL;
SSkipList
*
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int
),
true
,
false
,
true
,
getkey
);
SSkipList *pSkipList = tSkipListCreate(MAX_SKIP_LIST_LEVEL, TSDB_DATA_TYPE_INT, sizeof(int));
for (int32_t i = 0; i < 10000; ++i) {
for
(
int32_t
i
=
0
;
i
<
200
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
5
;
++
j
)
{
key.i64Key = i;
tSkipListPut(pSkipList, "", &key, 1);
int32_t
level
,
size
;
tSkipListNewNodeInfo
(
pSkipList
,
&
level
,
&
size
);
SSkipListNode
*
d
=
(
SSkipListNode
*
)
calloc
(
1
,
size
+
sizeof
(
int32_t
));
d
->
level
=
level
;
int32_t
*
key
=
(
int32_t
*
)
SL_GET_NODE_KEY
(
pSkipList
,
d
);
key
[
0
]
=
i
;
tSkipListPut
(
pSkipList
,
d
);
}
}
tSkipListPrint(pSkipList, 1);
for
(
int32_t
i
=
0
;
i
<
100
;
++
i
)
{
key.i64Key = rand() % 1000;
int32_t size = tSkipListGets(pSkipList, &key, &pNodes);
assert(size == 5);
SSkipListKey
key
;
SArray
*
nodes
=
tSkipListGet
(
pSkipList
,
(
char
*
)(
&
i
));
assert
(
taosArrayGetSize
(
nodes
)
==
5
);
taosArrayDestroy
(
nodes
);
}
tfree(pNodes);
int32_t
key
=
101
;
uint32_t
num
=
tSkipListRemove
(
pSkipList
,
(
char
*
)(
&
key
));
assert
(
num
==
5
);
SArray
*
nodes
=
tSkipListGet
(
pSkipList
,
(
char
*
)(
&
key
));
assert
(
taosArrayGetSize
(
nodes
)
==
0
);
taosArrayDestroy
(
nodes
);
key
=
102
;
SSkipListIterator
*
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)(
&
key
),
TSDB_DATA_TYPE_INT
,
TSDB_ORDER_ASC
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
assert
(
tSkipListIterNext
(
iter
)
==
true
);
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
int32_t
*
val
=
(
int32_t
*
)
SL_GET_NODE_KEY
(
pSkipList
,
node
);
assert
((
i
<
5
)
==
((
*
val
)
==
key
));
}
tSkipListDestroyIter
(
iter
);
iter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
char
*
)(
&
key
),
TSDB_DATA_TYPE_INT
,
TSDB_ORDER_DESC
);
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
assert
(
tSkipListIterNext
(
iter
)
==
true
);
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
int32_t
*
val
=
(
int32_t
*
)
SL_GET_NODE_KEY
(
pSkipList
,
node
);
assert
((
i
<
5
)
==
((
*
val
)
==
key
));
}
tSkipListDestroyIter
(
iter
);
tSkipListDestroy
(
pSkipList
);
#endif
}
}
// namespace
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录