Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5fcc8102
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
5fcc8102
编写于
4月 20, 2020
作者:
S
slguan
提交者:
GitHub
4月 20, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1671 from taosdata/feature/query
[td-98] optimize put performance by comparing the minimum key of skip…
上级
84c3955a
e591a3eb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
4 deletion
+24
-4
src/util/inc/tskiplist.h
src/util/inc/tskiplist.h
+2
-0
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+22
-4
未找到文件。
src/util/inc/tskiplist.h
浏览文件 @
5fcc8102
...
...
@@ -50,6 +50,8 @@ typedef struct SSkipListNode {
#define SL_GET_NODE_DATA(n) ((char *)(n) + SL_NODE_HEADER_SIZE((n)->level))
#define SL_GET_NODE_KEY(s, n) ((s)->keyFn(SL_GET_NODE_DATA(n)))
#define SL_GET_SL_MIN_KEY(s) (SL_GET_NODE_KEY((s), SL_GET_FORWARD_POINTER((s)->pHead, 0)))
#define SL_GET_NODE_LEVEL(n) *(uint8_t *)((n))
/*
...
...
src/util/src/tskiplist.c
浏览文件 @
5fcc8102
...
...
@@ -71,7 +71,8 @@ memset(pNode, 0, SL_NODE_HEADER_SIZE(_l));\
} while(0)
static
void
tSkipListDoInsert
(
SSkipList
*
pSkipList
,
SSkipListNode
**
forward
,
SSkipListNode
*
pNode
);
static
SSkipListNode
*
tSkipListDoAppend
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
static
SSkipListNode
*
tSkipListPushBack
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
static
SSkipListNode
*
tSkipListPushFront
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
);
static
SSkipListIterator
*
doCreateSkipListIterator
(
SSkipList
*
pSkipList
,
int32_t
order
);
static
bool
initForwardBackwardPtr
(
SSkipList
*
pSkipList
)
{
...
...
@@ -207,10 +208,17 @@ SSkipListNode *tSkipListPut(SSkipList *pSkipList, SSkipListNode *pNode) {
pthread_rwlock_wrlock
(
pSkipList
->
lock
);
}
//
the new key is greater than the last key of skiplist append it at last position
//
if the new key is greater than the maximum key of skip list, push back this node at the end of skip list
char
*
newDatakey
=
SL_GET_NODE_KEY
(
pSkipList
,
pNode
);
if
(
pSkipList
->
size
==
0
||
pSkipList
->
comparFn
(
pSkipList
->
lastKey
,
newDatakey
)
<
0
)
{
return
tSkipListDoAppend
(
pSkipList
,
pNode
);
return
tSkipListPushBack
(
pSkipList
,
pNode
);
}
// if the new key is less than the minimum key of skip list, push front this node at the front of skip list
assert
(
pSkipList
->
size
>
0
);
char
*
minKey
=
SL_GET_SL_MIN_KEY
(
pSkipList
);
if
(
pSkipList
->
comparFn
(
newDatakey
,
minKey
)
<
0
)
{
return
tSkipListPushFront
(
pSkipList
,
pNode
);
}
// find the appropriated position to insert data
...
...
@@ -269,7 +277,17 @@ void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, SSkipListN
}
}
SSkipListNode
*
tSkipListDoAppend
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
)
{
SSkipListNode
*
tSkipListPushFront
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
)
{
SSkipListNode
*
forward
[
MAX_SKIP_LIST_LEVEL
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pSkipList
->
level
;
++
i
)
{
forward
[
i
]
=
pSkipList
->
pHead
;
}
tSkipListDoInsert
(
pSkipList
,
forward
,
pNode
);
return
pNode
;
}
SSkipListNode
*
tSkipListPushBack
(
SSkipList
*
pSkipList
,
SSkipListNode
*
pNode
)
{
// do clear pointer area
DO_MEMSET_PTR_AREA
(
pNode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录