Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
48dc335c
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看板
未验证
提交
48dc335c
编写于
11月 11, 2020
作者:
H
huili
提交者:
GitHub
11月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4186 from taosdata/feature/TD-2061
Feature/td 2061
上级
13ed70f6
8cb80a39
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
29 deletion
+29
-29
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+29
-29
未找到文件。
src/util/src/tskiplist.c
浏览文件 @
48dc335c
...
...
@@ -24,8 +24,8 @@ static SSkipListNode * getPriorNode(SSkipList *pSkipList, const char *val, in
static
void
tSkipListRemoveNodeImpl
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
static
void
tSkipListCorrectLevel
(
SSkipList
*
pSkipList
);
static
SSkipListIterator
*
doCreateSkipListIterator
(
SSkipList
*
pSkipList
,
int32_t
order
);
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
for
ward
,
SSkipListNode
*
pNode
);
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
for
ward
,
void
*
pData
);
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
back
ward
,
SSkipListNode
*
pNode
);
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
back
ward
,
void
*
pData
);
static
SSkipListNode
*
tSkipListNewNode
(
uint8_t
level
);
#define tSkipListFreeNode(n) tfree((n))
...
...
@@ -108,17 +108,17 @@ void tSkipListDestroy(SSkipList *pSkipList) {
SSkipListNode
*
tSkipListPut
(
SSkipList
*
pSkipList
,
void
*
pData
)
{
if
(
pSkipList
==
NULL
||
pData
==
NULL
)
return
NULL
;
SSkipListNode
*
for
ward
[
MAX_SKIP_LIST_LEVEL
]
=
{
0
};
SSkipListNode
*
back
ward
[
MAX_SKIP_LIST_LEVEL
]
=
{
0
};
uint8_t
dupMode
=
SL_DUP_MODE
(
pSkipList
);
SSkipListNode
*
pNode
=
NULL
;
tSkipListWLock
(
pSkipList
);
bool
hasDup
=
tSkipListGetPosToPut
(
pSkipList
,
for
ward
,
pData
);
bool
hasDup
=
tSkipListGetPosToPut
(
pSkipList
,
back
ward
,
pData
);
if
(
hasDup
&&
(
dupMode
==
SL_DISCARD_DUP_KEY
||
dupMode
==
SL_UPDATE_DUP_KEY
))
{
if
(
dupMode
==
SL_UPDATE_DUP_KEY
)
{
pNode
=
SL_NODE_GET_
FORWARD_POINTER
(
for
ward
[
0
],
0
);
pNode
=
SL_NODE_GET_
BACKWARD_POINTER
(
back
ward
[
0
],
0
);
atomic_store_ptr
(
&
(
pNode
->
pData
),
pData
);
}
}
else
{
...
...
@@ -126,7 +126,7 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, void *pData) {
if
(
pNode
!=
NULL
)
{
pNode
->
pData
=
pData
;
tSkipListDoInsert
(
pSkipList
,
for
ward
,
pNode
);
tSkipListDoInsert
(
pSkipList
,
back
ward
,
pNode
);
}
}
...
...
@@ -310,7 +310,7 @@ void tSkipListPrint(SSkipList *pSkipList, int16_t nlevel) {
}
}
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
for
ward
,
SSkipListNode
*
pNode
)
{
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
back
ward
,
SSkipListNode
*
pNode
)
{
for
(
int32_t
i
=
0
;
i
<
pNode
->
level
;
++
i
)
{
if
(
i
>=
pSkipList
->
level
)
{
SL_NODE_GET_FORWARD_POINTER
(
pNode
,
i
)
=
pSkipList
->
pTail
;
...
...
@@ -318,14 +318,14 @@ static void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSk
SL_NODE_GET_FORWARD_POINTER
(
pSkipList
->
pHead
,
i
)
=
pNode
;
SL_NODE_GET_BACKWARD_POINTER
(
pSkipList
->
pTail
,
i
)
=
pNode
;
}
else
{
SSkipListNode
*
x
=
for
ward
[
i
];
SL_NODE_GET_
BACK
WARD_POINTER
(
pNode
,
i
)
=
x
;
SSkipListNode
*
x
=
back
ward
[
i
];
SL_NODE_GET_
FOR
WARD_POINTER
(
pNode
,
i
)
=
x
;
SSkipListNode
*
next
=
SL_NODE_GET_FOR
WARD_POINTER
(
x
,
i
);
SL_NODE_GET_
BACKWARD_POINTER
(
next
,
i
)
=
pNode
;
SSkipListNode
*
prev
=
SL_NODE_GET_BACK
WARD_POINTER
(
x
,
i
);
SL_NODE_GET_
FORWARD_POINTER
(
prev
,
i
)
=
pNode
;
SL_NODE_GET_
FORWARD_POINTER
(
pNode
,
i
)
=
next
;
SL_NODE_GET_
FORWARD_POINTER
(
x
,
i
)
=
pNode
;
SL_NODE_GET_
BACKWARD_POINTER
(
x
,
i
)
=
pNode
;
SL_NODE_GET_
BACKWARD_POINTER
(
pNode
,
i
)
=
prev
;
}
}
...
...
@@ -371,57 +371,57 @@ static FORCE_INLINE int tSkipListUnlock(SSkipList *pSkipList) {
return
0
;
}
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
for
ward
,
void
*
pData
)
{
static
bool
tSkipListGetPosToPut
(
SSkipList
*
pSkipList
,
SSkipListNode
**
back
ward
,
void
*
pData
)
{
int
compare
=
0
;
bool
hasDupKey
=
false
;
char
*
pDataKey
=
pSkipList
->
keyFn
(
pData
);
if
(
pSkipList
->
size
==
0
)
{
for
(
int
i
=
0
;
i
<
pSkipList
->
level
;
i
++
)
{
forward
[
i
]
=
pSkipList
->
pHead
;
backward
[
i
]
=
pSkipList
->
pTail
;
}
}
else
{
char
*
pKey
=
NULL
;
// Compare m
in
key
pKey
=
SL_GET_M
IN
_KEY
(
pSkipList
);
// Compare m
ax
key
pKey
=
SL_GET_M
AX
_KEY
(
pSkipList
);
compare
=
pSkipList
->
comparFn
(
pDataKey
,
pKey
);
if
(
compare
<
=
0
)
{
if
(
compare
>
=
0
)
{
for
(
int
i
=
0
;
i
<
pSkipList
->
level
;
i
++
)
{
forward
[
i
]
=
pSkipList
->
pHead
;
backward
[
i
]
=
pSkipList
->
pTail
;
}
return
(
compare
==
0
);
}
// Compare m
ax
key
pKey
=
SL_GET_M
AX
_KEY
(
pSkipList
);
// Compare m
in
key
pKey
=
SL_GET_M
IN
_KEY
(
pSkipList
);
compare
=
pSkipList
->
comparFn
(
pDataKey
,
pKey
);
if
(
compare
>
0
)
{
if
(
compare
<
0
)
{
for
(
int
i
=
0
;
i
<
pSkipList
->
level
;
i
++
)
{
forward
[
i
]
=
SL_NODE_GET_BACKWARD_POINTER
(
pSkipList
->
pTail
,
i
);
backward
[
i
]
=
SL_NODE_GET_FORWARD_POINTER
(
pSkipList
->
pHead
,
i
);
}
return
(
compare
==
0
);
}
SSkipListNode
*
px
=
pSkipList
->
p
Head
;
SSkipListNode
*
px
=
pSkipList
->
p
Tail
;
for
(
int
i
=
pSkipList
->
level
-
1
;
i
>=
0
;
--
i
)
{
SSkipListNode
*
p
=
SL_NODE_GET_
FOR
WARD_POINTER
(
px
,
i
);
while
(
p
!=
pSkipList
->
p
Tail
)
{
SSkipListNode
*
p
=
SL_NODE_GET_
BACK
WARD_POINTER
(
px
,
i
);
while
(
p
!=
pSkipList
->
p
Head
)
{
pKey
=
SL_GET_NODE_KEY
(
pSkipList
,
p
);
compare
=
pSkipList
->
comparFn
(
pKey
,
pDataKey
);
if
(
compare
>
=
0
)
{
if
(
compare
<
=
0
)
{
if
(
compare
==
0
&&
!
hasDupKey
)
hasDupKey
=
true
;
break
;
}
else
{
px
=
p
;
p
=
SL_NODE_GET_
FOR
WARD_POINTER
(
px
,
i
);
p
=
SL_NODE_GET_
BACK
WARD_POINTER
(
px
,
i
);
}
}
for
ward
[
i
]
=
px
;
back
ward
[
i
]
=
px
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录