Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cfada1cc
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cfada1cc
编写于
5月 03, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more sl refact
上级
d3487c88
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
53 addition
and
10 deletion
+53
-10
include/util/tskiplist2.h
include/util/tskiplist2.h
+6
-0
source/util/src/tskiplist2.c
source/util/src/tskiplist2.c
+47
-10
未找到文件。
include/util/tskiplist2.h
浏览文件 @
cfada1cc
...
@@ -32,6 +32,7 @@ typedef int32_t (*tslCmprFn)(const void *pKey1, int32_t nKey1, const void *pKey2
...
@@ -32,6 +32,7 @@ typedef int32_t (*tslCmprFn)(const void *pKey1, int32_t nKey1, const void *pKey2
// SSkipList2
// SSkipList2
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
);
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
);
int32_t
slClose
(
SSkipList2
*
pSl
);
int32_t
slClose
(
SSkipList2
*
pSl
);
int32_t
slClear
(
SSkipList2
*
pSl
);
// SSLCursor
// SSLCursor
int32_t
slcOpen
(
SSkipList2
*
pSl
,
SSLCursor
*
pSlc
);
int32_t
slcOpen
(
SSkipList2
*
pSl
,
SSLCursor
*
pSlc
);
...
@@ -56,6 +57,11 @@ struct SSLCfg {
...
@@ -56,6 +57,11 @@ struct SSLCfg {
void
(
*
xFree
)(
void
*
,
void
*
);
void
(
*
xFree
)(
void
*
,
void
*
);
};
};
struct
SSLCursor
{
SSkipList2
*
pSl
;
SSLNode
**
forwards
[
SL_MAX_LEVEL
];
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/util/src/tskiplist2.c
浏览文件 @
cfada1cc
...
@@ -27,11 +27,7 @@ struct SSkipList2 {
...
@@ -27,11 +27,7 @@ struct SSkipList2 {
uint32_t
seed
;
uint32_t
seed
;
int32_t
size
;
int32_t
size
;
const
SSLCfg
*
pCfg
;
const
SSLCfg
*
pCfg
;
};
SSLNode
*
pHead
[];
struct
SSLCursor
{
SSkipList2
*
pSl
;
SSLNode
*
forwards
[
SL_MAX_LEVEL
];
};
};
static
void
*
slMalloc
(
void
*
pPool
,
int32_t
size
);
static
void
*
slMalloc
(
void
*
pPool
,
int32_t
size
);
...
@@ -48,25 +44,66 @@ const SSLCfg slDefaultCfg = {.maxLevel = SL_MAX_LEVEL,
...
@@ -48,25 +44,66 @@ const SSLCfg slDefaultCfg = {.maxLevel = SL_MAX_LEVEL,
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
)
{
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
)
{
SSkipList2
*
pSl
=
NULL
;
SSkipList2
*
pSl
=
NULL
;
int32_t
size
;
*
ppSl
=
NULL
;
*
ppSl
=
NULL
;
if
(
pCfg
==
NULL
)
pCfg
=
&
slDefaultCfg
;
if
(
pCfg
==
NULL
)
pCfg
=
&
slDefaultCfg
;
// check cfg (TODO)
// check config (TODO)
// malloc handle
size
=
sizeof
(
*
pSl
)
+
sizeof
(
SSLNode
*
)
*
pCfg
->
maxLevel
*
2
;
pSl
=
pCfg
->
xMalloc
(
pCfg
->
pPool
,
size
);
if
(
pSl
==
NULL
)
{
return
-
1
;
}
pSl
->
level
=
0
;
pSl
->
seed
=
taosRand
();
pSl
->
size
=
0
;
pSl
->
pCfg
=
pCfg
;
// init an empty skiplist
for
(
int32_t
i
=
0
;
i
<
pCfg
->
maxLevel
*
2
;
i
++
)
{
pSl
->
pHead
[
i
]
=
NULL
;
}
// create handle
pSl
=
pCfg
->
xMalloc
(
pCfg
->
pPool
,
sizeof
(
*
pSl
));
// (TODO)
*
ppSl
=
pSl
;
*
ppSl
=
pSl
;
return
0
;
return
0
;
}
}
int32_t
slClose
(
SSkipList2
*
pSl
)
{
int32_t
slClose
(
SSkipList2
*
pSl
)
{
// TODO
if
(
pSl
)
{
slClear
(
pSl
);
if
(
pSl
->
pCfg
->
xFree
)
{
pSl
->
pCfg
->
xFree
(
pSl
->
pCfg
->
pPool
,
pSl
);
}
}
return
0
;
}
int32_t
slClear
(
SSkipList2
*
pSl
)
{
// loop to clear sl
for
(;;)
{
// (TODO)
}
// init sl (TODO)
return
0
;
return
0
;
}
}
int32_t
slcOpen
(
SSkipList2
*
pSl
,
SSLCursor
*
pSlc
)
{
int32_t
slcOpen
(
SSkipList2
*
pSl
,
SSLCursor
*
pSlc
)
{
pSlc
->
pSl
=
pSl
;
for
(
int
i
=
0
;
i
<
SL_MAX_LEVEL
;
i
++
)
{
if
(
i
<
pSl
->
pCfg
->
maxLevel
)
{
}
else
{
pSlc
->
forwards
[
i
]
=
NULL
;
}
}
// TODO
// TODO
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录