Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8ba20611
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8ba20611
编写于
9月 23, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1575]
上级
40b6ce67
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
5 deletion
+31
-5
src/util/inc/tskiplist.h
src/util/inc/tskiplist.h
+1
-0
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+30
-5
未找到文件。
src/util/inc/tskiplist.h
浏览文件 @
8ba20611
...
@@ -136,6 +136,7 @@ typedef struct SSkipListIterator {
...
@@ -136,6 +136,7 @@ typedef struct SSkipListIterator {
SSkipListNode
*
cur
;
SSkipListNode
*
cur
;
int32_t
step
;
// the number of nodes that have been checked already
int32_t
step
;
// the number of nodes that have been checked already
int32_t
order
;
// order of the iterator
int32_t
order
;
// order of the iterator
SSkipListNode
*
next
;
// next points to the true qualified node in skip list
}
SSkipListIterator
;
}
SSkipListIterator
;
/**
/**
...
...
src/util/src/tskiplist.c
浏览文件 @
8ba20611
...
@@ -79,9 +79,12 @@ static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t
...
@@ -79,9 +79,12 @@ static SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t
// when order is TSDB_ORDER_ASC, return the last node with key less than val
// 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
// 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
;
__compar_fn_t
comparFn
=
pSkipList
->
comparFn
;
SSkipListNode
*
pNode
=
NULL
;
SSkipListNode
*
pNode
=
NULL
;
if
(
pCur
!=
NULL
)
{
*
pCur
=
NULL
;
}
if
(
order
==
TSDB_ORDER_ASC
)
{
if
(
order
==
TSDB_ORDER_ASC
)
{
pNode
=
pSkipList
->
pHead
;
pNode
=
pSkipList
->
pHead
;
...
@@ -93,6 +96,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
...
@@ -93,6 +96,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
pNode
=
p
;
pNode
=
p
;
p
=
SL_GET_FORWARD_POINTER
(
p
,
i
);
p
=
SL_GET_FORWARD_POINTER
(
p
,
i
);
}
else
{
}
else
{
if
(
pCur
!=
NULL
)
{
*
pCur
=
p
;
}
break
;
break
;
}
}
}
}
...
@@ -107,6 +113,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
...
@@ -107,6 +113,9 @@ static SSkipListNode* getPriorNode(SSkipList* pSkipList, const char* val, int32_
pNode
=
p
;
pNode
=
p
;
p
=
SL_GET_BACKWARD_POINTER
(
p
,
i
);
p
=
SL_GET_BACKWARD_POINTER
(
p
,
i
);
}
else
{
}
else
{
if
(
pCur
!=
NULL
)
{
*
pCur
=
p
;
}
break
;
break
;
}
}
}
}
...
@@ -295,7 +304,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) {
...
@@ -295,7 +304,7 @@ SArray* tSkipListGet(SSkipList *pSkipList, SSkipListKey key) {
pthread_rwlock_wrlock
(
pSkipList
->
lock
);
pthread_rwlock_wrlock
(
pSkipList
->
lock
);
}
}
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
,
NULL
);
while
(
1
)
{
while
(
1
)
{
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
0
);
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
0
);
if
(
p
==
pSkipList
->
pTail
)
{
if
(
p
==
pSkipList
->
pTail
)
{
...
@@ -452,7 +461,7 @@ uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) {
...
@@ -452,7 +461,7 @@ uint32_t tSkipListRemove(SSkipList *pSkipList, SSkipListKey key) {
pthread_rwlock_wrlock
(
pSkipList
->
lock
);
pthread_rwlock_wrlock
(
pSkipList
->
lock
);
}
}
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
);
SSkipListNode
*
pNode
=
getPriorNode
(
pSkipList
,
key
,
TSDB_ORDER_ASC
,
NULL
);
while
(
1
)
{
while
(
1
)
{
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
0
);
SSkipListNode
*
p
=
SL_GET_FORWARD_POINTER
(
pNode
,
0
);
if
(
p
==
pSkipList
->
pTail
)
{
if
(
p
==
pSkipList
->
pTail
)
{
...
@@ -545,7 +554,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char*
...
@@ -545,7 +554,7 @@ SSkipListIterator *tSkipListCreateIterFromVal(SSkipList* pSkipList, const char*
pthread_rwlock_rdlock
(
pSkipList
->
lock
);
pthread_rwlock_rdlock
(
pSkipList
->
lock
);
}
}
iter
->
cur
=
getPriorNode
(
pSkipList
,
val
,
order
);
iter
->
cur
=
getPriorNode
(
pSkipList
,
val
,
order
,
&
iter
->
next
);
if
(
pSkipList
->
lock
)
{
if
(
pSkipList
->
lock
)
{
pthread_rwlock_unlock
(
pSkipList
->
lock
);
pthread_rwlock_unlock
(
pSkipList
->
lock
);
...
@@ -567,8 +576,22 @@ bool tSkipListIterNext(SSkipListIterator *iter) {
...
@@ -567,8 +576,22 @@ bool tSkipListIterNext(SSkipListIterator *iter) {
if
(
iter
->
order
==
TSDB_ORDER_ASC
)
{
// ascending order iterate
if
(
iter
->
order
==
TSDB_ORDER_ASC
)
{
// ascending order iterate
iter
->
cur
=
SL_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
cur
=
SL_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_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
}
else
{
// descending order iterate
}
else
{
// descending order iterate
iter
->
cur
=
SL_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
cur
=
SL_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_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
}
}
if
(
pSkipList
->
lock
)
{
if
(
pSkipList
->
lock
)
{
...
@@ -715,9 +738,11 @@ SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order)
...
@@ -715,9 +738,11 @@ SSkipListIterator* doCreateSkipListIterator(SSkipList *pSkipList, int32_t order)
iter
->
order
=
order
;
iter
->
order
=
order
;
if
(
order
==
TSDB_ORDER_ASC
)
{
if
(
order
==
TSDB_ORDER_ASC
)
{
iter
->
cur
=
pSkipList
->
pHead
;
iter
->
cur
=
pSkipList
->
pHead
;
iter
->
next
=
SL_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
}
else
{
}
else
{
iter
->
cur
=
pSkipList
->
pTail
;
iter
->
cur
=
pSkipList
->
pTail
;
iter
->
next
=
SL_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
}
}
return
iter
;
return
iter
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录