Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
b0b119
TDengine
提交
f15535af
TDengine
项目概览
b0b119
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f15535af
编写于
4月 15, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-100
上级
bc5396e9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
94 addition
and
88 deletion
+94
-88
src/vnode/tsdb/inc/tsdbMain.h
src/vnode/tsdb/inc/tsdbMain.h
+1
-1
src/vnode/tsdb/src/tsdbRWHelper.c
src/vnode/tsdb/src/tsdbRWHelper.c
+93
-87
未找到文件。
src/vnode/tsdb/inc/tsdbMain.h
浏览文件 @
f15535af
...
...
@@ -419,7 +419,7 @@ typedef struct {
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
SHelperCfg
*
pCfg
);
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
);
void
tsdb
Clear
Helper
(
SRWHelper
*
pHelper
);
void
tsdb
Reset
Helper
(
SRWHelper
*
pHelper
);
// --------- For set operations
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
...
...
src/vnode/tsdb/src/tsdbRWHelper.c
浏览文件 @
f15535af
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdbMain.h"
#include "tchecksum.h"
#define adjustMem(ptr, size, expectedSize) \
do { \
...
...
@@ -25,17 +26,11 @@
// Local function definitions
static
int
tsdbCheckHelperCfg
(
SHelperCfg
*
pCfg
);
static
void
tsdbInitHelperFile
(
SHelperFile
*
pHFile
);
static
int
tsdbInitHelperRead
(
SRWHelper
*
pHelper
);
// static int tsdbInitHelperWrite(SRWHelper *pHelper);
static
int
tsdbInitHelperFile
(
SRWHelper
*
pHelper
);
static
void
tsdbClearHelperFile
(
SHelperFile
*
pHFile
);
static
void
tsdbDestroyHelperRead
(
SRWHelper
*
pHelper
);
static
void
tsdbDestroyHelperWrite
(
SRWHelper
*
pHelper
);
static
void
tsdbClearHelperRead
(
SRWHelper
*
pHelper
);
static
void
tsdbClearHelperWrite
(
SRWHelper
*
pHelper
);
static
bool
tsdbShouldCreateNewLast
(
SRWHelper
*
pHelper
);
static
int
tsdbWriteBlockToFile
(
SRWHelper
*
pHelper
,
SFile
*
pFile
,
SDataCols
*
pDataCols
,
int
rowsToWrite
,
SCompBlock
*
pCompBlock
,
bool
isLast
,
bool
isSuperBlock
);
static
int
tsdbWriteBlockToFile
(
SRWHelper
*
pHelper
,
SFile
*
pFile
,
SDataCols
*
pDataCols
,
int
rowsToWrite
,
SCompBlock
*
pCompBlock
,
bool
isLast
,
bool
isSuperBlock
);
static
int
compareKeyBlock
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbMergeDataWithBlock
(
SRWHelper
*
pHelper
,
int
blkIdx
,
SDataCols
*
pDataCols
);
// static int nRowsLEThan(SDataCols *pDataCols, int maxKey);
...
...
@@ -45,23 +40,82 @@ static int tsdbAddSubBlock(SRWHelper *pHelper, SCompBlock *pCompBlock, int blkId
static
int
tsdbUpdateSuperBlock
(
SRWHelper
*
pHelper
,
SCompBlock
*
pCompBlock
,
int
blkIdx
);
static
int
tsdbGetRowsInRange
(
SDataCols
*
pDataCols
,
int
minKey
,
int
maxKey
);
// ---------- Operations on Helper File part
static
void
tsdbResetHelperFileImpl
(
SRWHelper
*
pHelper
)
{
memset
((
void
*
)
&
pHelper
->
files
,
0
,
sizeof
(
pHelper
->
files
));
pHelper
->
files
.
fid
=
-
1
;
pHelper
->
files
.
headF
.
fd
=
-
1
;
pHelper
->
files
.
dataF
.
fd
=
-
1
;
pHelper
->
files
.
lastF
.
fd
=
-
1
;
pHelper
->
files
.
nHeadF
.
fd
=
-
1
;
pHelper
->
files
.
nLastF
.
fd
=
-
1
;
}
static
int
tsdbInitHelperFile
(
SRWHelper
*
pHelper
)
{
pHelper
->
compIdxSize
=
sizeof
(
SCompIdx
)
*
pHelper
->
config
.
maxTables
+
sizeof
(
TSCKSUM
);
pHelper
->
pCompIdx
=
(
SCompIdx
*
)
malloc
(
pHelper
->
compIdxSize
);
if
(
pHelper
->
pCompIdx
==
NULL
)
return
-
1
;
tsdbResetHelperFileImpl
(
pHelper
);
return
0
;
}
static
void
tsdbDestroyHelperFile
(
SRWHelper
*
pHelper
)
{
tsdbCloseHelperFile
(
pHelper
,
false
);
tfree
(
pHelper
->
pCompIdx
);
}
// ---------- Operations on Helper Table part
static
void
tsdbResetHelperTableImpl
(
SRWHelper
*
pHelper
)
{
memset
((
void
*
)
&
pHelper
->
tableInfo
,
0
,
sizeof
(
SHelperTable
));
pHelper
->
hasOldLastBlock
=
false
;
}
static
void
tsdbInitHelperTable
(
SRWHelper
*
pHelper
)
{
tsdbResetHelperTableImpl
(
pHelper
);
}
static
void
tsdbDestroyHelperTable
(
SRWHelper
*
pHelper
)
{
return
;
}
// ---------- Operations on Helper Block part
static
void
tsdbResetHelperBlockImpl
(
SRWHelper
*
pHelper
)
{
tdResetDataCols
(
pHelper
->
pDataCols
[
0
]);
tdResetDataCols
(
pHelper
->
pDataCols
[
1
]);
}
static
int
tsdbInitHelperBlock
(
SRWHelper
*
pHelper
)
{
pHelper
->
pDataCols
[
0
]
=
tdNewDataCols
(
pHelper
->
config
.
maxRowSize
,
pHelper
->
config
.
maxCols
,
pHelper
->
config
.
maxRows
);
pHelper
->
pDataCols
[
1
]
=
tdNewDataCols
(
pHelper
->
config
.
maxRowSize
,
pHelper
->
config
.
maxCols
,
pHelper
->
config
.
maxRows
);
if
(
pHelper
->
pDataCols
[
0
]
==
NULL
||
pHelper
->
pDataCols
[
1
]
==
NULL
)
return
-
1
;
tsdbResetHelperBlockImpl
(
pHelper
);
return
0
;
}
static
void
tsdbDestroyHelperBlock
(
SRWHelper
*
pHelper
)
{
tdFreeDataCols
(
pHelper
->
pDataCols
[
0
]);
tdFreeDataCols
(
pHelper
->
pDataCols
[
1
]);
}
// ------------------------------------------ OPERATIONS FOR OUTSIDE ------------------------------------------
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
SHelperCfg
*
pCfg
)
{
if
(
pHelper
==
NULL
||
pCfg
==
NULL
||
tsdbCheckHelperCfg
(
pCfg
)
<
0
)
return
-
1
;
memset
((
void
*
)
pHelper
,
0
,
sizeof
(
*
pHelper
));
// Init global configuration
pHelper
->
config
=
*
pCfg
;
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
tsdbInitHelperFile
(
&
(
pHelper
->
files
));
if
(
tsdbInitHelperRead
(
pHelper
)
<
0
)
goto
_err
;
// Init file part
if
(
tsdbInitHelperFile
(
pHelper
)
<
0
)
goto
_err
;
pHelper
->
pDataCols
[
0
]
=
tdNewDataCols
(
pCfg
->
maxRowSize
,
pCfg
->
maxCols
,
pCfg
->
maxRows
);
pHelper
->
pDataCols
[
1
]
=
tdNewDataCols
(
pCfg
->
maxRowSize
,
pCfg
->
maxCols
,
pCfg
->
maxRows
);
if
((
pHelper
->
pDataCols
[
0
]
==
NULL
)
||
(
pHelper
->
pDataCols
[
1
]
==
NULL
))
goto
_err
;
// Init table part
tsdbInitHelperTable
(
pHelper
);
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
// Init block part
if
(
tsdbInitHelperBlock
(
pHelper
)
<
0
)
goto
_err
;
return
0
;
...
...
@@ -71,25 +125,36 @@ _err:
}
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
==
NULL
)
return
;
tsdbClearHelperFile
(
&
(
pHelper
->
files
));
tsdbDestroyHelperRead
(
pHelper
);
tsdbDestroyHelperWrite
(
pHelper
);
if
(
pHelper
)
{
tsdbDestroyHelperFile
(
pHelper
);
tsdbDestroyHelperTable
(
pHelper
);
tsdbDestroyHelperBlock
(
pHelper
);
memset
((
void
*
)
pHelper
,
0
,
sizeof
(
*
pHelper
));
}
}
void
tsdbClearHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
==
NULL
)
return
;
tsdbClearHelperFile
(
&
(
pHelper
->
files
));
tsdbClearHelperRead
(
pHelper
);
tsdbClearHelperWrite
(
pHelper
);
void
tsdbResetHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
)
{
// Reset the block part
tsdbResetHelperBlockImpl
(
pHelper
);
// Reset the table part
tsdbResetHelperTableImpl
(
pHelper
);
// Reset the file part
tsdbCloseHelperFile
(
pHelper
,
false
);
tsdbResetHelperFileImpl
(
pHelper
);
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
}
}
// ------------ Operations for read/write purpose
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
)
{
ASSERT
(
pHelper
!=
NULL
&&
pGroup
!=
NULL
);
// Clear the helper object
tsdb
Clear
Helper
(
pHelper
);
tsdb
Reset
Helper
(
pHelper
);
ASSERT
(
pHelper
->
state
==
TSDB_HELPER_CLEAR_STATE
);
...
...
@@ -519,14 +584,6 @@ static int tsdbCheckHelperCfg(SHelperCfg *pCfg) {
return
0
;
}
static
void
tsdbInitHelperFile
(
SHelperFile
*
pHFile
)
{
pHFile
->
fid
=
-
1
;
pHFile
->
headF
.
fd
=
-
1
;
pHFile
->
dataF
.
fd
=
-
1
;
pHFile
->
lastF
.
fd
=
-
1
;
pHFile
->
nHeadF
.
fd
=
-
1
;
pHFile
->
nLastF
.
fd
=
-
1
;
}
static
void
tsdbClearHelperFile
(
SHelperFile
*
pHFile
)
{
pHFile
->
fid
=
-
1
;
...
...
@@ -553,57 +610,6 @@ static void tsdbClearHelperFile(SHelperFile *pHFile) {
}
static
int
tsdbInitHelperRead
(
SRWHelper
*
pHelper
)
{
SHelperCfg
*
pCfg
=
&
(
pHelper
->
config
);
pHelper
->
compIdxSize
=
pCfg
->
maxTables
*
sizeof
(
SCompIdx
);
if
((
pHelper
->
pCompIdx
=
(
SCompIdx
*
)
malloc
(
pHelper
->
compIdxSize
))
==
NULL
)
return
-
1
;
return
0
;
}
static
void
tsdbDestroyHelperRead
(
SRWHelper
*
pHelper
)
{
tfree
(
pHelper
->
pCompIdx
);
pHelper
->
compIdxSize
=
0
;
tfree
(
pHelper
->
pCompInfo
);
pHelper
->
compInfoSize
=
0
;
tfree
(
pHelper
->
pCompData
);
pHelper
->
compDataSize
=
0
;
tdFreeDataCols
(
pHelper
->
pDataCols
[
0
]);
tdFreeDataCols
(
pHelper
->
pDataCols
[
1
]);
}
// static int tsdbInitHelperWrite(SRWHelper *pHelper) {
// SHelperCfg *pCfg = &(pHelper->config);
// // pHelper->wCompIdxSize = pCfg->maxTables * sizeof(SCompIdx);
// // if ((pHelper->pWCompIdx = (SCompIdx *)malloc(pHelper->wCompIdxSize)) == NULL) return -1;
// return 0;
// }
static
void
tsdbDestroyHelperWrite
(
SRWHelper
*
pHelper
)
{
// tfree(pHelper->pWCompIdx);
// pHelper->wCompIdxSize = 0;
// tfree(pHelper->pWCompInfo);
// pHelper->wCompInfoSize = 0;
// tfree(pHelper->pWCompData);
// pHelper->wCompDataSize = 0;
}
static
void
tsdbClearHelperRead
(
SRWHelper
*
pHelper
)
{
// TODO
}
static
void
tsdbClearHelperWrite
(
SRWHelper
*
pHelper
)
{
// TODO
}
static
bool
tsdbShouldCreateNewLast
(
SRWHelper
*
pHelper
)
{
// TODO
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录