Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a035fdb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
9a035fdb
编写于
5月 09, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact tsdb
上级
04e690b5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
249 deletion
+38
-249
include/util/tskiplist2.h
include/util/tskiplist2.h
+0
-70
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+38
-4
source/util/src/tskiplist2.c
source/util/src/tskiplist2.c
+0
-175
未找到文件。
include/util/tskiplist2.h
已删除
100644 → 0
浏览文件 @
04e690b5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_SKIPLIST2_H_
#define _TD_UTIL_SKIPLIST2_H_
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#define SL_MAX_LEVEL 15
typedef
struct
SSkipList2
SSkipList2
;
typedef
struct
SSLCursor
SSLCursor
;
typedef
struct
SSLCfg
SSLCfg
;
typedef
struct
SSLNode
SSLNode
;
typedef
int32_t
(
*
tslCmprFn
)(
const
void
*
pKey1
,
int32_t
nKey1
,
const
void
*
pKey2
,
int32_t
nKey2
);
// SSkipList2
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
);
int32_t
slClose
(
SSkipList2
*
pSl
);
int32_t
slClear
(
SSkipList2
*
pSl
);
// SSLCursor
int32_t
slcOpen
(
SSkipList2
*
pSl
,
SSLCursor
*
pSlc
);
int32_t
slcClose
(
SSLCursor
*
pSlc
);
int32_t
slcMoveTo
(
SSLCursor
*
pSlc
,
const
void
*
pKey
,
int32_t
nKey
);
int32_t
slcMoveToNext
(
SSLCursor
*
pSlc
);
int32_t
slcMoveToPrev
(
SSLCursor
*
pSlc
);
int32_t
slcMoveToFirst
(
SSLCursor
*
pSlc
);
int32_t
slcMoveToLast
(
SSLCursor
*
pSlc
);
int32_t
slcPut
(
SSLCursor
*
pSlc
,
const
void
*
pKey
,
int32_t
nKey
,
const
void
*
pData
,
int32_t
nData
);
int32_t
slcGet
(
SSLCursor
*
pSlc
,
const
void
**
ppKey
,
int32_t
*
nKey
,
const
void
**
ppData
,
int32_t
*
nData
);
int32_t
slcDrop
(
SSLCursor
*
pSlc
);
// struct
struct
SSLCfg
{
int8_t
maxLevel
;
int32_t
nKey
;
int32_t
nData
;
tslCmprFn
cmprFn
;
void
*
pPool
;
void
*
(
*
xMalloc
)(
void
*
,
int32_t
size
);
void
(
*
xFree
)(
void
*
,
void
*
);
};
struct
SSLCursor
{
SSkipList2
*
pSl
;
SSLNode
**
forwards
[
SL_MAX_LEVEL
];
};
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_SKIPLIST2_H_*/
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
9a035fdb
...
...
@@ -61,7 +61,7 @@ struct SMemData {
struct
SMemSkipListCurosr
{
SMemSkipList
*
pSl
;
SMemSkipListNode
*
forwards
[]
;
SMemSkipListNode
*
pNodeC
;
};
typedef
struct
{
...
...
@@ -70,6 +70,8 @@ typedef struct {
const
STSRow
*
pRow
;
}
STsdbRow
;
#define SL_MAX_LEVEL 15
#define HASH_BUCKET(SUID, UID, NBUCKET) (TABS((SUID) + (UID)) % (NBUCKET))
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l)*2)
...
...
@@ -90,6 +92,9 @@ static int32_t tsdbMemSkipListCursorCreate(int8_t maxLevel, SMemSkipListCurosr *
static
void
tsdbMemSkipListCursorDestroy
(
SMemSkipListCurosr
*
pSlc
);
static
void
tsdbMemSkipListCursorInit
(
SMemSkipListCurosr
*
pSlc
,
SMemSkipList
*
pSl
);
static
void
tsdbMemSkipListCursorPut
(
SMemSkipListCurosr
*
pSlc
,
SMemSkipListNode
*
pNode
);
static
int32_t
tsdbMemSkipListCursorMoveTo
(
SMemSkipListCurosr
*
pSlc
,
int64_t
version
,
TSKEY
ts
,
int32_t
flags
);
static
int32_t
tsdbMemSkipListCursorMoveToNext
(
SMemSkipListCurosr
*
pSlc
);
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
);
// SMemTable
int32_t
tsdbMemTableCreate2
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTb
)
{
...
...
@@ -211,6 +216,7 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
}
// move cursor
tsdbMemSkipListCursorMoveTo
(
pMemTb
->
pSlc
,
version
,
tRow
.
pRow
->
ts
,
0
);
// encode row
int8_t
level
=
tsdbMemSkipListRandLevel
(
&
pMemData
->
sl
);
...
...
@@ -290,9 +296,9 @@ static void tsdbMemSkipListCursorDestroy(SMemSkipListCurosr *pSlc) { taosMemoryF
static
void
tsdbMemSkipListCursorInit
(
SMemSkipListCurosr
*
pSlc
,
SMemSkipList
*
pSl
)
{
SMemSkipListNode
*
pHead
=
SL_HEAD_NODE
(
pSl
);
pSlc
->
pSl
=
pSl
;
for
(
int8_t
iLevel
=
0
;
iLevel
<
pSl
->
maxLevel
;
iLevel
++
)
{
pSlc
->
forwards
[
iLevel
]
=
pHead
;
}
//
for (int8_t iLevel = 0; iLevel < pSl->maxLevel; iLevel++) {
//
pSlc->forwards[iLevel] = pHead;
//
}
}
static
void
tsdbMemSkipListCursorPut
(
SMemSkipListCurosr
*
pSlc
,
SMemSkipListNode
*
pNode
)
{
...
...
@@ -310,4 +316,32 @@ static void tsdbMemSkipListCursorPut(SMemSkipListCurosr *pSlc, SMemSkipListNode
}
pSl
->
size
+=
1
;
}
static
int32_t
tsdbMemSkipListCursorMoveTo
(
SMemSkipListCurosr
*
pSlc
,
int64_t
version
,
TSKEY
ts
,
int32_t
flags
)
{
SMemSkipListNode
**
pForwards
=
NULL
;
SMemSkipList
*
pSl
=
pSlc
->
pSl
;
int8_t
maxLevel
=
pSl
->
maxLevel
;
SMemSkipListNode
*
pHead
=
SL_HEAD_NODE
(
pSl
);
SMemSkipListNode
*
pTail
=
SL_TAIL_NODE
(
pSl
);
for
(
int8_t
iLevel
=
0
;
iLevel
<
maxLevel
;
iLevel
++
)
{
pForwards
[
iLevel
]
=
pHead
;
}
for
(
int8_t
iLevel
=
maxLevel
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
if
(
iLevel
<
pSl
->
level
)
{
}
}
return
0
;
}
static
int32_t
tsdbMemSkipListCursorMoveToNext
(
SMemSkipListCurosr
*
pSlc
)
{
// TODO
return
0
;
}
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
)
{
// TODO
return
0
;
}
\ No newline at end of file
source/util/src/tskiplist2.c
已删除
100644 → 0
浏览文件 @
04e690b5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tskiplist2.h"
struct
SSLNode
{
int8_t
level
;
SSLNode
*
forwards
[];
};
struct
SSkipList2
{
int8_t
level
;
uint32_t
seed
;
int32_t
size
;
const
SSLCfg
*
pCfg
;
SSLNode
*
pHead
[];
};
static
void
*
slMalloc
(
void
*
pPool
,
int32_t
size
);
static
void
slFree
(
void
*
pPool
,
void
*
p
);
static
int32_t
slCmprFn
(
const
void
*
pKey
,
int32_t
nKey
,
const
void
*
pData
,
int32_t
nData
);
const
SSLCfg
slDefaultCfg
=
{.
maxLevel
=
SL_MAX_LEVEL
,
.
nKey
=
-
1
,
.
nData
=
-
1
,
.
cmprFn
=
slCmprFn
,
.
pPool
=
NULL
,
.
xMalloc
=
slMalloc
,
.
xFree
=
slFree
};
int32_t
slOpen
(
const
SSLCfg
*
pCfg
,
SSkipList2
**
ppSl
)
{
SSkipList2
*
pSl
=
NULL
;
int32_t
size
;
*
ppSl
=
NULL
;
if
(
pCfg
==
NULL
)
pCfg
=
&
slDefaultCfg
;
// 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
;
}
*
ppSl
=
pSl
;
return
0
;
}
int32_t
slClose
(
SSkipList2
*
pSl
)
{
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
;
}
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
return
0
;
}
int32_t
slcClose
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
int32_t
slcMoveTo
(
SSLCursor
*
pSlc
,
const
void
*
pKey
,
int32_t
nKey
)
{
// TODO
return
0
;
}
int32_t
slcMoveToNext
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
int32_t
slcMoveToPrev
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
int32_t
slcMoveToFirst
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
int32_t
slcMoveToLast
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
int32_t
slcPut
(
SSLCursor
*
pSlc
,
const
void
*
pKey
,
int32_t
nKey
,
const
void
*
pData
,
int32_t
nData
)
{
// TODO
return
0
;
}
int32_t
slcGet
(
SSLCursor
*
pSlc
,
const
void
**
ppKey
,
int32_t
*
nKey
,
const
void
**
ppData
,
int32_t
*
nData
)
{
// TODO
return
0
;
}
int32_t
slcDrop
(
SSLCursor
*
pSlc
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
void
*
slMalloc
(
void
*
pPool
,
int32_t
size
)
{
return
taosMemoryMalloc
(
size
);
}
static
FORCE_INLINE
void
slFree
(
void
*
pPool
,
void
*
p
)
{
taosMemoryFree
(
p
);
}
static
int32_t
slCmprFn
(
const
void
*
pKey1
,
int32_t
nKey1
,
const
void
*
pKey2
,
int32_t
nKey2
)
{
ASSERT
(
nKey1
>=
0
&&
nKey2
>=
0
);
int32_t
nKey
=
nKey1
>
nKey2
?
nKey2
:
nKey1
;
int32_t
c
;
c
=
memcmp
(
pKey1
,
pKey2
,
nKey
);
if
(
c
==
0
)
{
if
(
nKey1
>
nKey2
)
{
c
=
1
;
}
else
if
(
nKey1
<
nKey2
)
{
c
=
-
1
;
}
}
return
c
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录