Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de32cab3
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
de32cab3
编写于
6月 04, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more progress
上级
c7c47788
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
129 addition
and
14 deletion
+129
-14
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+1
-0
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+14
-0
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+104
-0
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+10
-14
未找到文件。
source/dnode/vnode/CMakeLists.txt
浏览文件 @
de32cab3
...
...
@@ -36,6 +36,7 @@ target_sources(
# tsdb
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCommit2.c"
"src/tsdb/tsdbFile.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbOpen.c"
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
de32cab3
...
...
@@ -46,6 +46,10 @@ void tsdbMemTableDestroy2(SMemTable *pMemTable);
int32_t
tsdbInsertTableData2
(
STsdb
*
pTsdb
,
int64_t
version
,
SVSubmitBlk
*
pSubmitBlk
);
int32_t
tsdbDeleteTableData2
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
// tsdbCommit2.c ==============================================================================================
int32_t
tsdbBegin2
(
STsdb
*
pTsdb
);
int32_t
tsdbCommit2
(
STsdb
*
pTsdb
);
// tsdbMemTable ================
typedef
struct
STsdbRow
STsdbRow
;
typedef
struct
STbData
STbData
;
...
...
@@ -877,6 +881,16 @@ struct SDelOp {
SDelOp
*
pNext
;
};
struct
SMemTable
{
STsdb
*
pTsdb
;
int32_t
nRef
;
TSDBKEY
minKey
;
TSDBKEY
maxKey
;
int64_t
nRows
;
SArray
*
aSkmInfo
;
SArray
*
aMemData
;
};
static
FORCE_INLINE
int
tsdbKeyCmprFn
(
const
void
*
p1
,
const
void
*
p2
)
{
TSDBKEY
*
pKey1
=
(
TSDBKEY
*
)
p1
;
TSDBKEY
*
pKey2
=
(
TSDBKEY
*
)
p2
;
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
0 → 100644
浏览文件 @
de32cab3
/*
* 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 "tsdb.h"
typedef
struct
{
SMemTable
*
pMemTable
;
SArray
*
aBlkIdx
;
}
SCommitH
;
static
int32_t
tsdbStartCommit
(
SCommitH
*
pCHandle
,
STsdb
*
pTsdb
);
static
int32_t
tsdbEndCommit
(
SCommitH
*
pCHandle
);
static
int32_t
tsdbCommitToFile
(
SCommitH
*
pCHandle
,
int32_t
fid
);
int32_t
tsdbBegin2
(
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
ASSERT
(
pTsdb
->
mem
==
NULL
);
code
=
tsdbMemTableCreate2
(
pTsdb
,
(
SMemTable
**
)
&
pTsdb
->
mem
);
if
(
code
)
{
tsdbError
(
"vgId:%d failed to begin TSDB since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
tstrerror
(
code
));
goto
_exit
;
}
_exit:
return
code
;
}
int32_t
tsdbCommit2
(
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
SCommitH
ch
=
{
0
};
// start to commit
code
=
tsdbStartCommit
(
&
ch
,
pTsdb
);
if
(
code
)
{
goto
_exit
;
}
// commit
int32_t
sfid
;
// todo
int32_t
efid
;
// todo
for
(
int32_t
fid
=
sfid
;
fid
<=
efid
;
fid
++
)
{
code
=
tsdbCommitToFile
(
&
ch
,
fid
);
if
(
code
)
{
goto
_err
;
}
}
// end commit
code
=
tsdbEndCommit
(
&
ch
);
if
(
code
)
{
goto
_exit
;
}
_exit:
return
code
;
_err:
// TODO: rollback
return
code
;
}
static
int32_t
tsdbStartCommit
(
SCommitH
*
pCHandle
,
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
ASSERT
(
pTsdb
->
imem
==
NULL
&&
pTsdb
->
mem
);
pTsdb
->
imem
=
pTsdb
->
mem
;
pTsdb
->
mem
=
NULL
;
return
code
;
}
static
int32_t
tsdbEndCommit
(
SCommitH
*
pCHandle
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
tsdbCommitToFile
(
SCommitH
*
pCHandle
,
int32_t
fid
)
{
int32_t
code
=
0
;
TSKEY
fidSKey
;
TSKEY
fidEKey
;
// check if there are data in the time range
for
(
int32_t
iMemData
=
0
;
iMemData
<
taosArrayGetSize
(
pCHandle
->
pMemTable
->
aMemData
);
iMemData
++
)
{
/* code */
}
// has data, do commit to file
return
code
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
de32cab3
...
...
@@ -43,14 +43,10 @@ struct SMemData {
SMemSkipList
sl
;
};
struct
SMemTable
{
STsdb
*
pTsdb
;
int32_t
nRef
;
TSDBKEY
minKey
;
TSDBKEY
maxKey
;
int64_t
nRows
;
SArray
*
pArray
;
// SArray<SMemData>
};
typedef
struct
{
tb_uid_t
uid
;
STSchema
*
pTSchema
;
}
SSkmInfo
;
#define SL_MAX_LEVEL 5
...
...
@@ -85,8 +81,8 @@ int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable) {
pMemTable
->
minKey
=
(
TSDBKEY
){.
version
=
INT64_MAX
,
.
ts
=
TSKEY_MAX
};
pMemTable
->
maxKey
=
(
TSDBKEY
){.
version
=
-
1
,
.
ts
=
TSKEY_MIN
};
pMemTable
->
nRows
=
0
;
pMemTable
->
pArray
=
taosArrayInit
(
512
,
sizeof
(
SMemData
*
));
if
(
pMemTable
->
pArray
==
NULL
)
{
pMemTable
->
aMemData
=
taosArrayInit
(
512
,
sizeof
(
SMemData
*
));
if
(
pMemTable
->
aMemData
==
NULL
)
{
taosMemoryFree
(
pMemTable
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -101,7 +97,7 @@ _err:
}
void
tsdbMemTableDestroy2
(
SMemTable
*
pMemTable
)
{
taosArrayDestroyEx
(
pMemTable
->
pArray
,
NULL
/*TODO*/
);
taosArrayDestroyEx
(
pMemTable
->
aMemData
,
NULL
/*TODO*/
);
taosMemoryFree
(
pMemTable
);
}
...
...
@@ -196,9 +192,9 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
int8_t
maxLevel
=
pMemTable
->
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
slLevel
;
// get
idx
=
taosArraySearchIdx
(
pMemTable
->
pArray
,
&
pMemDataT
,
memDataPCmprFn
,
TD_GE
);
idx
=
taosArraySearchIdx
(
pMemTable
->
aMemData
,
&
pMemDataT
,
memDataPCmprFn
,
TD_GE
);
if
(
idx
>=
0
)
{
pMemData
=
(
SMemData
*
)
taosArrayGet
(
pMemTable
->
pArray
,
idx
);
pMemData
=
(
SMemData
*
)
taosArrayGet
(
pMemTable
->
aMemData
,
idx
);
if
(
memDataPCmprFn
(
&
pMemDataT
,
&
pMemData
)
==
0
)
goto
_exit
;
}
...
...
@@ -230,7 +226,7 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
}
if
(
idx
<
0
)
idx
=
0
;
if
(
taosArrayInsert
(
pMemTable
->
pArray
,
idx
,
&
pMemData
)
==
NULL
)
{
if
(
taosArrayInsert
(
pMemTable
->
aMemData
,
idx
,
&
pMemData
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录