Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3cad99a1
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
3cad99a1
编写于
5月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
a06bf6e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
11 deletion
+35
-11
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+35
-11
未找到文件。
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
3cad99a1
...
...
@@ -76,6 +76,8 @@ struct SMemSkipListCurosr {
#define SL_HEAD_NODE_FORWARD(n, l) SL_NODE_FORWARD(n, l)
#define SL_TAIL_NODE_BACKWARD(n, l) SL_NODE_FORWARD(n, l)
static
int8_t
tsdbMemSkipListRandLevel
(
SMemSkipList
*
pSl
);
// SMemTable
int32_t
tsdbMemTableCreate2
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTb
)
{
SMemTable
*
pMemTb
=
NULL
;
...
...
@@ -176,20 +178,19 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
// do insert data to SMemData
SMemSkipListCurosr
slc
=
{
0
};
const
uint8_t
*
p
=
pSubmitBlk
->
pData
;
const
uint8_t
*
pt
;
const
STSRow
*
pRow
;
uint
64
_t
szRow
;
uint
32
_t
szRow
;
SDecoder
decoder
=
{
0
};
// tCoderInit(&coder, TD_LITTLE_ENDIAN, pSubmitBlk->pData, pSubmitBlk->nData, TD_DECODER
);
tDecoderInit
(
&
decoder
,
pSubmitBlk
->
pData
,
pSubmitBlk
->
nData
);
for
(;;)
{
// if (tDecodeIsEnd(&coder)) break;
if
(
tDecodeIsEnd
(
&
decoder
))
break
;
if
(
tDecodeBinary
(
&
decoder
,
(
const
uint8_t
**
)
&
pRow
,
&
szRow
)
<
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
// if (tDecodeBinary(&coder, (const uint8_t **)&pRow, &szRow) < 0) {
// terrno = TSDB_CODE_INVALID_MSG;
// return -1;
// }
// check the row (todo)
// // move the cursor to position to write (todo)
...
...
@@ -197,7 +198,9 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
// tsdbMemSkipListCursorMoveTo(&slc, pTSRow, version, &c);
// ASSERT(c);
// // encode row
// encode row
int8_t
level
=
tsdbMemSkipListRandLevel
(
&
pMemData
->
sl
);
// int8_t level = tsdbMemSkipListRandLevel(&pMemData->sl);
// int32_t tsize = SL_NODE_SIZE(level) + sizeof(version) + (p - pt);
// pSlNode = vnodeBufPoolMalloc(pPool, tsize);
...
...
@@ -215,7 +218,7 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
if
(
pRow
->
ts
<
pMemData
->
minKey
)
pMemData
->
minKey
=
pRow
->
ts
;
if
(
pRow
->
ts
>
pMemData
->
maxKey
)
pMemData
->
maxKey
=
pRow
->
ts
;
}
// tCoderClear(&
coder);
tDecoderClear
(
&
de
coder
);
// tsdbMemSkipListCursorClose(&slc);
// update status
...
...
@@ -228,4 +231,25 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
if
(
pMemTb
->
maxVer
==
-
1
||
pMemTb
->
maxVer
<
version
)
pMemTb
->
maxVer
=
version
;
return
0
;
}
static
int8_t
tsdbMemSkipListRandLevel
(
SMemSkipList
*
pSl
)
{
int8_t
level
=
1
;
const
uint32_t
factor
=
4
;
if
(
pSl
->
size
)
{
while
((
taosRandR
(
&
pSl
->
seed
)
%
factor
)
==
0
&&
level
<
pSl
->
maxLevel
)
{
level
++
;
}
if
(
level
>
pSl
->
level
)
{
if
(
pSl
->
level
<
pSl
->
maxLevel
)
{
level
=
pSl
->
level
+
1
;
}
else
{
level
=
pSl
->
level
;
}
}
}
return
level
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录