Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7e8fc3b2
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7e8fc3b2
编写于
4月 18, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-100
上级
366b07fb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
46 deletion
+45
-46
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+6
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+3
-13
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+32
-12
src/tsdb/tests/tsdbTests.cpp
src/tsdb/tests/tsdbTests.cpp
+4
-18
未找到文件。
src/tsdb/inc/tsdbMain.h
浏览文件 @
7e8fc3b2
...
...
@@ -443,13 +443,16 @@ typedef struct {
#define helperHasState(h, s) ((((h)->state) & (s)) == (s))
#define blockAtIdx(h, idx) ((h)->pCompInfo->blocks + idx)
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
SHelperCfg
*
pCfg
);
int
tsdbInitReadHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
int
tsdbInitWriteHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
);
// int tsdbInitHelper(SRWHelper *pHelper, SHelperCfg *pCfg);
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
);
void
tsdbResetHelper
(
SRWHelper
*
pHelper
);
// --------- For set operations
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
SHelperTable
*
pHelperTable
,
STSchema
*
pSchema
);
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
// void tsdbSetHelperTable(SRWHelper *pHelper, SHelperTable *pHelperTable, STSchema *pSchema);
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
STable
*
pTable
,
STsdbRepo
*
pRepo
);
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
);
// --------- For read operations
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
7e8fc3b2
...
...
@@ -400,6 +400,7 @@ int tsdbInitTableCfg(STableCfg *config, ETableType type, int64_t uid, int32_t ti
config
->
superUid
=
TSDB_INVALID_SUPER_TABLE_ID
;
config
->
tableId
.
uid
=
uid
;
config
->
tableId
.
tid
=
tid
;
config
->
name
=
strdup
(
"test1"
);
return
0
;
}
...
...
@@ -873,16 +874,7 @@ static void *tsdbCommitData(void *arg) {
return
NULL
;
}
// Create a write helper to commit data
SHelperCfg
hcfg
=
{.
type
=
TSDB_WRITE_HELPER
,
.
maxTables
=
pCfg
->
maxTables
,
.
maxRowSize
=
pMeta
->
maxRowBytes
,
.
maxRows
=
pCfg
->
maxRowsPerFileBlock
,
.
maxCols
=
pMeta
->
maxCols
,
.
minRowsPerFileBlock
=
pCfg
->
minRowsPerFileBlock
,
.
maxRowsPerFileBlock
=
pCfg
->
maxRowsPerFileBlock
,
.
compress
=
pCfg
->
compression
};
if
(
tsdbInitHelper
(
&
whelper
,
&
hcfg
)
<
0
)
goto
_exit
;
if
(
tsdbInitWriteHelper
(
&
whelper
,
pRepo
)
<
0
)
goto
_exit
;
if
((
pDataCols
=
tdNewDataCols
(
pMeta
->
maxRowBytes
,
pMeta
->
maxCols
,
pCfg
->
maxRowsPerFileBlock
))
==
NULL
)
goto
_exit
;
int
sfid
=
tsdbGetKeyFileId
(
pCache
->
imem
->
keyFirst
,
pCfg
->
daysPerFile
,
pCfg
->
precision
);
...
...
@@ -898,7 +890,6 @@ static void *tsdbCommitData(void *arg) {
_exit:
tdFreeDataCols
(
pDataCols
);
tsdbDestroyHelper
(
&
whelper
);
tsdbDestroyTableIters
(
iters
,
pCfg
->
maxTables
);
tsdbLockRepo
(
arg
);
...
...
@@ -948,8 +939,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
SSkipListIterator
*
pIter
=
iters
[
tid
];
// Set the helper and the buffer dataCols object to help to write this table
SHelperTable
hTable
=
{.
uid
=
pTable
->
tableId
.
uid
,
.
tid
=
pTable
->
tableId
.
tid
,
.
sversion
=
pTable
->
sversion
};
tsdbSetHelperTable
(
pHelper
,
&
hTable
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
tsdbSetHelperTable
(
pHelper
,
pTable
,
pRepo
);
tdInitDataCols
(
pDataCols
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
// Loop to write the data in the cache to files. If no data to write, just break the loop
...
...
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
7e8fc3b2
...
...
@@ -18,7 +18,7 @@
#include "talgo.h"
// Local function definitions
static
int
tsdbCheckHelperCfg
(
SHelperCfg
*
pCfg
);
//
static int tsdbCheckHelperCfg(SHelperCfg *pCfg);
static
int
tsdbInitHelperFile
(
SRWHelper
*
pHelper
);
// static void tsdbClearHelperFile(SHelperFile *pHFile);
static
bool
tsdbShouldCreateNewLast
(
SRWHelper
*
pHelper
);
...
...
@@ -102,14 +102,21 @@ static void tsdbDestroyHelperBlock(SRWHelper *pHelper) {
tdFreeDataCols
(
pHelper
->
pDataCols
[
1
]);
}
// ------------------------------------------ OPERATIONS FOR OUTSIDE ------------------------------------------
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
SHelperCfg
*
pCfg
)
{
if
(
pHelper
==
NULL
||
pCfg
==
NULL
||
tsdbCheckHelperCfg
(
pCfg
)
<
0
)
return
-
1
;
static
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
,
tsdb_rw_helper_t
type
)
{
if
(
pHelper
==
NULL
||
pRepo
==
NULL
)
return
-
1
;
memset
((
void
*
)
pHelper
,
0
,
sizeof
(
*
pHelper
));
// Init global configuration
pHelper
->
config
=
*
pCfg
;
pHelper
->
config
.
type
=
type
;
pHelper
->
config
.
maxTables
=
pRepo
->
config
.
maxTables
;
pHelper
->
config
.
maxRowSize
=
pRepo
->
tsdbMeta
->
maxRowBytes
;
pHelper
->
config
.
maxRows
=
pRepo
->
config
.
maxRowsPerFileBlock
;
pHelper
->
config
.
maxCols
=
pRepo
->
tsdbMeta
->
maxCols
;
pHelper
->
config
.
minRowsPerFileBlock
=
pRepo
->
config
.
minRowsPerFileBlock
;
pHelper
->
config
.
maxRowsPerFileBlock
=
pRepo
->
config
.
maxRowsPerFileBlock
;
pHelper
->
config
.
compress
=
pRepo
->
config
.
compression
;
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
// Init file part
...
...
@@ -128,6 +135,15 @@ _err:
return
-
1
;
}
// ------------------------------------------ OPERATIONS FOR OUTSIDE ------------------------------------------
int
tsdbInitReadHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
)
{
return
tsdbInitHelper
(
pHelper
,
pRepo
,
TSDB_READ_HELPER
);
}
int
tsdbInitWriteHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
)
{
return
tsdbInitHelper
(
pHelper
,
pRepo
,
TSDB_WRITE_HELPER
);
}
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
)
{
tsdbDestroyHelperFile
(
pHelper
);
...
...
@@ -243,18 +259,22 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
return
0
;
}
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
S
HelperTable
*
pHelperTable
,
STSchema
*
pSchema
)
{
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
S
Table
*
pTable
,
STsdbRepo
*
pRepo
)
{
ASSERT
(
helperHasState
(
pHelper
,
TSDB_HELPER_FILE_SET_AND_OPEN
|
TSDB_HELPER_IDX_LOAD
));
// Clear members and state used by previous table
tsdbResetHelperTable
(
pHelper
);
ASSERT
(
pHelper
->
state
==
(
TSDB_HELPER_FILE_SET_AND_OPEN
|
TSDB_HELPER_IDX_LOAD
));
pHelper
->
tableInfo
=
*
pHelperTable
;
pHelper
->
tableInfo
.
tid
=
pTable
->
tableId
.
tid
;
pHelper
->
tableInfo
.
uid
=
pTable
->
tableId
.
uid
;
pHelper
->
tableInfo
.
sversion
=
pTable
->
sversion
;
STSchema
*
pSchema
=
tsdbGetTableSchema
(
pRepo
->
tsdbMeta
,
pTable
);
tdInitDataCols
(
pHelper
->
pDataCols
[
0
],
pSchema
);
tdInitDataCols
(
pHelper
->
pDataCols
[
1
],
pSchema
);
SCompIdx
*
pIdx
=
pHelper
->
pCompIdx
+
p
HelperTable
->
tid
;
SCompIdx
*
pIdx
=
pHelper
->
pCompIdx
+
p
Table
->
tableId
.
tid
;
if
(
pIdx
->
offset
>
0
&&
pIdx
->
hasLast
)
{
pHelper
->
hasOldLastBlock
=
true
;
}
...
...
@@ -610,10 +630,10 @@ _err:
return
-
1
;
}
static
int
tsdbCheckHelperCfg
(
SHelperCfg
*
pCfg
)
{
// TODO
return
0
;
}
//
static int tsdbCheckHelperCfg(SHelperCfg *pCfg) {
//
// TODO
//
return 0;
//
}
// static void tsdbClearHelperFile(SHelperFile *pHFile) {
// pHFile->fid = -1;
...
...
src/tsdb/tests/tsdbTests.cpp
浏览文件 @
7e8fc3b2
...
...
@@ -191,29 +191,15 @@ TEST(TsdbTest, createRepo) {
// Read from file
SRWHelper
rhelper
;
SHelperCfg
helperCfg
=
{
.
type
=
TSDB_READ_HELPER
,
.
maxTables
=
repo
->
config
.
maxTables
,
.
maxRowSize
=
repo
->
tsdbMeta
->
maxRowBytes
,
.
maxRows
=
repo
->
config
.
maxRowsPerFileBlock
,
.
maxCols
=
repo
->
tsdbMeta
->
maxCols
,
.
minRowsPerFileBlock
=
repo
->
config
.
minRowsPerFileBlock
,
.
maxRowsPerFileBlock
=
repo
->
config
.
maxRowsPerFileBlock
,
.
compress
=
repo
->
config
.
compression
,
};
tsdbInitHelper
(
&
rhelper
,
&
helperCfg
);
tsdbInitReadHelper
(
&
rhelper
,
repo
);
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
repo
->
tsdbFileH
,
1833
);
ASSERT_NE
(
pFGroup
,
nullptr
);
ASSERT_GE
(
tsdbSetAndOpenHelperFile
(
&
rhelper
,
pFGroup
),
0
);
SHelperTable
htable
=
{
.
uid
=
tCfg
.
tableId
.
uid
,
.
tid
=
tCfg
.
tableId
.
tid
,
.
sversion
=
tCfg
.
sversion
};
tsdbSetHelperTable
(
&
rhelper
,
&
htable
,
schema
);
STable
*
pTable
=
tsdbGetTableByUid
(
repo
->
tsdbMeta
,
tCfg
.
tableId
.
uid
);
ASSERT_NE
(
pTable
,
nullptr
);
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
repo
);
ASSERT_EQ
(
tsdbLoadCompInfo
(
&
rhelper
,
NULL
),
0
);
ASSERT_EQ
(
tsdbLoadBlockData
(
&
rhelper
,
0
,
NULL
),
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录