Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fba58c76
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看板
提交
fba58c76
编写于
5月 09, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact TSDB
上级
9a035fdb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
26 deletion
+34
-26
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+34
-26
未找到文件。
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
fba58c76
...
@@ -95,6 +95,7 @@ static void tsdbMemSkipListCursorPut(SMemSkipListCurosr *pSlc, SMemSkipListNo
...
@@ -95,6 +95,7 @@ static void tsdbMemSkipListCursorPut(SMemSkipListCurosr *pSlc, SMemSkipListNo
static
int32_t
tsdbMemSkipListCursorMoveTo
(
SMemSkipListCurosr
*
pSlc
,
int64_t
version
,
TSKEY
ts
,
int32_t
flags
);
static
int32_t
tsdbMemSkipListCursorMoveTo
(
SMemSkipListCurosr
*
pSlc
,
int64_t
version
,
TSKEY
ts
,
int32_t
flags
);
static
int32_t
tsdbMemSkipListCursorMoveToNext
(
SMemSkipListCurosr
*
pSlc
);
static
int32_t
tsdbMemSkipListCursorMoveToNext
(
SMemSkipListCurosr
*
pSlc
);
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
);
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
);
static
SMemSkipListNode
*
tsdbMemSkipListNodeCreate
(
SVBufPool
*
pPool
,
SMemSkipList
*
pSl
,
const
STsdbRow
*
pTRow
);
// SMemTable
// SMemTable
int32_t
tsdbMemTableCreate2
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTb
)
{
int32_t
tsdbMemTableCreate2
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTb
)
{
...
@@ -201,15 +202,18 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
...
@@ -201,15 +202,18 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
}
}
// do insert data to SMemData
// do insert data to SMemData
STsdbRow
tRow
=
{.
version
=
version
};
SMemSkipListNode
*
forwards
[
SL_MAX_LEVEL
];
SEncoder
ec
=
{
0
};
SMemSkipListNode
*
pNode
;
SDecoder
dc
=
{
0
};
STsdbRow
tRow
=
{.
version
=
version
};
SEncoder
ec
=
{
0
};
SDecoder
dc
=
{
0
};
tDecoderInit
(
&
dc
,
pSubmitBlk
->
pData
,
pSubmitBlk
->
nData
);
tDecoderInit
(
&
dc
,
pSubmitBlk
->
pData
,
pSubmitBlk
->
nData
);
tsdbMemSkipListCursorInit
(
pMemTb
->
pSlc
,
&
pMemData
->
sl
);
tsdbMemSkipListCursorInit
(
pMemTb
->
pSlc
,
&
pMemData
->
sl
);
for
(;;)
{
for
(;;)
{
if
(
tDecodeIsEnd
(
&
dc
))
break
;
if
(
tDecodeIsEnd
(
&
dc
))
break
;
// decode row
if
(
tDecodeBinary
(
&
dc
,
(
const
uint8_t
**
)
&
tRow
.
pRow
,
&
tRow
.
szRow
)
<
0
)
{
if
(
tDecodeBinary
(
&
dc
,
(
const
uint8_t
**
)
&
tRow
.
pRow
,
&
tRow
.
szRow
)
<
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
return
-
1
;
...
@@ -219,22 +223,12 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
...
@@ -219,22 +223,12 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
tsdbMemSkipListCursorMoveTo
(
pMemTb
->
pSlc
,
version
,
tRow
.
pRow
->
ts
,
0
);
tsdbMemSkipListCursorMoveTo
(
pMemTb
->
pSlc
,
version
,
tRow
.
pRow
->
ts
,
0
);
// encode row
// encode row
int8_t
level
=
tsdbMemSkipListRandLevel
(
&
pMemData
->
sl
);
pNode
=
tsdbMemSkipListNodeCreate
(
pPool
,
&
pMemData
->
sl
,
&
tRow
);
int32_t
tsize
;
int32_t
ret
;
tEncodeSize
(
tsdbEncodeRow
,
&
tRow
,
tsize
,
ret
);
SMemSkipListNode
*
pNode
=
vnodeBufPoolMalloc
(
pPool
,
tsize
+
SL_NODE_SIZE
(
level
));
if
(
pNode
==
NULL
)
{
if
(
pNode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
pNode
->
level
=
level
;
tEncoderInit
(
&
ec
,
(
uint8_t
*
)
SL_NODE_DATA
(
pNode
),
tsize
);
ret
=
tsdbEncodeRow
(
&
ec
,
&
tRow
);
ASSERT
(
ret
==
0
);
tEncoderClear
(
&
ec
);
// put the node
// put the node
tsdbMemSkipListCursorPut
(
pMemTb
->
pSlc
,
pNode
);
tsdbMemSkipListCursorPut
(
pMemTb
->
pSlc
,
pNode
);
...
@@ -258,14 +252,11 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
...
@@ -258,14 +252,11 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
static
FORCE_INLINE
int8_t
tsdbMemSkipListRandLevel
(
SMemSkipList
*
pSl
)
{
static
FORCE_INLINE
int8_t
tsdbMemSkipListRandLevel
(
SMemSkipList
*
pSl
)
{
int8_t
level
=
1
;
int8_t
level
=
1
;
int8_t
tlevel
;
int8_t
tlevel
=
TMIN
(
pSl
->
maxLevel
,
pSl
->
level
+
1
)
;
const
uint32_t
factor
=
4
;
const
uint32_t
factor
=
4
;
if
(
pSl
->
size
)
{
while
((
taosRandR
(
&
pSl
->
seed
)
%
factor
)
==
0
&&
level
<
tlevel
)
{
tlevel
=
TMIN
(
pSl
->
maxLevel
,
pSl
->
level
+
1
);
level
++
;
while
((
taosRandR
(
&
pSl
->
seed
)
%
factor
)
==
0
&&
level
<
tlevel
)
{
level
++
;
}
}
}
return
level
;
return
level
;
...
@@ -325,14 +316,12 @@ static int32_t tsdbMemSkipListCursorMoveTo(SMemSkipListCurosr *pSlc, int64_t ver
...
@@ -325,14 +316,12 @@ static int32_t tsdbMemSkipListCursorMoveTo(SMemSkipListCurosr *pSlc, int64_t ver
SMemSkipListNode
*
pHead
=
SL_HEAD_NODE
(
pSl
);
SMemSkipListNode
*
pHead
=
SL_HEAD_NODE
(
pSl
);
SMemSkipListNode
*
pTail
=
SL_TAIL_NODE
(
pSl
);
SMemSkipListNode
*
pTail
=
SL_TAIL_NODE
(
pSl
);
for
(
int8_t
iLevel
=
0
;
iLevel
<
maxLevel
;
iLevel
++
)
{
if
(
pSl
->
size
==
0
)
{
pForwards
[
iLevel
]
=
pHead
;
for
(
int8_t
iLevel
=
0
;
iLevel
<
pSl
->
maxLevel
;
iLevel
++
)
{
}
pForwards
[
iLevel
]
=
pHead
;
for
(
int8_t
iLevel
=
maxLevel
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
if
(
iLevel
<
pSl
->
level
)
{
}
}
}
}
return
0
;
return
0
;
}
}
...
@@ -344,4 +333,23 @@ static int32_t tsdbMemSkipListCursorMoveToNext(SMemSkipListCurosr *pSlc) {
...
@@ -344,4 +333,23 @@ static int32_t tsdbMemSkipListCursorMoveToNext(SMemSkipListCurosr *pSlc) {
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
)
{
static
int32_t
tsdbMemSkipListCursorMoveToPrev
(
SMemSkipListCurosr
*
pSlc
)
{
// TODO
// TODO
return
0
;
return
0
;
}
static
SMemSkipListNode
*
tsdbMemSkipListNodeCreate
(
SVBufPool
*
pPool
,
SMemSkipList
*
pSl
,
const
STsdbRow
*
pTRow
)
{
int32_t
tsize
;
int32_t
ret
;
int8_t
level
=
tsdbMemSkipListRandLevel
(
pSl
);
SMemSkipListNode
*
pNode
=
NULL
;
SEncoder
ec
=
{
0
};
tEncodeSize
(
tsdbEncodeRow
,
pTRow
,
tsize
,
ret
);
pNode
=
vnodeBufPoolMalloc
(
pPool
,
tsize
+
SL_NODE_SIZE
(
level
));
if
(
pNode
)
{
pNode
->
level
=
level
;
tEncoderInit
(
&
ec
,
(
uint8_t
*
)
SL_NODE_DATA
(
pNode
),
tsize
);
tsdbEncodeRow
(
&
ec
,
pTRow
);
tEncoderClear
(
&
ec
);
}
return
pNode
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录