Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f879d6b0
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
提交
f879d6b0
编写于
10月 28, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge develop
上级
951a0df6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
5 deletion
+30
-5
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+30
-5
未找到文件。
src/util/src/tskiplist.c
浏览文件 @
f879d6b0
...
...
@@ -20,7 +20,7 @@
#include "tutil.h"
static
int
initForwardBackwardPtr
(
SSkipList
*
pSkipList
);
static
SSkipListNode
*
getPriorNode
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
order
);
static
SSkipListNode
*
getPriorNode
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
order
,
SSkipListNode
**
pCur
);
static
void
tSkipListRemoveNodeImpl
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
static
void
tSkipListCorrectLevel
(
SSkipList
*
pSkipList
);
static
SSkipListIterator
*
doCreateSkipListIterator
(
SSkipList
*
pSkipList
,
int32_t
order
);
...
...
@@ -140,7 +140,7 @@ uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) {
tSkipListWLock
(
pSkipList
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
,
NULL
);
while
(
1
)
{
SSkipListNode
*
p
=
SL_NODE_GET_FORWARD_POINTER
(
pNode
,
0
);
if
(
p
==
pSkipList
->
pTail
)
{
...
...
@@ -167,7 +167,7 @@ SArray *tSkipListGet(SSkipList *pSkipList, SSkipListKey key) {
tSkipListRLock
(
pSkipList
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
,
NULL
);
while
(
1
)
{
SSkipListNode
*
p
=
SL_NODE_GET_FORWARD_POINTER
(
pNode
,
0
);
if
(
p
==
pSkipList
->
pTail
)
{
...
...
@@ -209,7 +209,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList *pSkipList, const char *
tSkipListRLock
(
pSkipList
);
iter
->
cur
=
getPriorNode
(
pSkipList
,
val
,
order
);
iter
->
cur
=
getPriorNode
(
pSkipList
,
val
,
order
,
&
(
iter
->
next
)
);
tSkipListUnlock
(
pSkipList
);
...
...
@@ -226,10 +226,24 @@ bool tSkipListIterNext(SSkipListIterator *iter) {
if
(
iter
->
order
==
TSDB_ORDER_ASC
)
{
if
(
iter
->
cur
==
pSkipList
->
pTail
)
return
false
;
iter
->
cur
=
SL_NODE_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
// a new node is inserted into between iter->cur and iter->next, ignore it
if
(
iter
->
cur
!=
iter
->
next
&&
(
iter
->
next
!=
NULL
))
{
iter
->
cur
=
iter
->
next
;
}
iter
->
next
=
SL_NODE_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
step
++
;
}
else
{
if
(
iter
->
cur
==
pSkipList
->
pHead
)
return
false
;
iter
->
cur
=
SL_NODE_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
// a new node is inserted into between iter->cur and iter->next, ignore it
if
(
iter
->
cur
!=
iter
->
next
&&
(
iter
->
next
!=
NULL
))
{
iter
->
cur
=
iter
->
next
;
}
iter
->
next
=
SL_NODE_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
step
++
;
}
...
...
@@ -327,8 +341,10 @@ static SSkipListIterator *doCreateSkipListIterator(SSkipList *pSkipList, int32_t
iter
->
order
=
order
;
if
(
order
==
TSDB_ORDER_ASC
)
{
iter
->
cur
=
pSkipList
->
pHead
;
iter
->
next
=
SL_NODE_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
}
else
{
iter
->
cur
=
pSkipList
->
pTail
;
iter
->
next
=
SL_NODE_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
}
return
iter
;
...
...
@@ -485,9 +501,12 @@ static FORCE_INLINE int32_t getSkipListRandLevel(SSkipList *pSkipList) {
// when order is TSDB_ORDER_ASC, return the last node with key less than val
// when order is TSDB_ORDER_DESC, return the first node with key large than val
static
SSkipListNode
*
getPriorNode
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
order
)
{
static
SSkipListNode
*
getPriorNode
(
SSkipList
*
pSkipList
,
const
char
*
val
,
int32_t
order
,
SSkipListNode
**
pCur
)
{
__compar_fn_t
comparFn
=
pSkipList
->
comparFn
;
SSkipListNode
*
pNode
=
NULL
;
if
(
pCur
!=
NULL
)
{
*
pCur
=
NULL
;
}
if
(
order
==
TSDB_ORDER_ASC
)
{
pNode
=
pSkipList
->
pHead
;
...
...
@@ -499,6 +518,9 @@ static SSkipListNode *getPriorNode(SSkipList *pSkipList, const char *val, int32_
pNode
=
p
;
p
=
SL_NODE_GET_FORWARD_POINTER
(
p
,
i
);
}
else
{
if
(
pCur
!=
NULL
)
{
*
pCur
=
p
;
}
break
;
}
}
...
...
@@ -513,6 +535,9 @@ static SSkipListNode *getPriorNode(SSkipList *pSkipList, const char *val, int32_
pNode
=
p
;
p
=
SL_NODE_GET_BACKWARD_POINTER
(
p
,
i
);
}
else
{
if
(
pCur
!=
NULL
)
{
*
pCur
=
p
;
}
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录