Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7e8fc3b2
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看板
提交
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 {
...
@@ -443,13 +443,16 @@ typedef struct {
#define helperHasState(h, s) ((((h)->state) & (s)) == (s))
#define helperHasState(h, s) ((((h)->state) & (s)) == (s))
#define blockAtIdx(h, idx) ((h)->pCompInfo->blocks + idx)
#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
tsdbDestroyHelper
(
SRWHelper
*
pHelper
);
void
tsdbResetHelper
(
SRWHelper
*
pHelper
);
void
tsdbResetHelper
(
SRWHelper
*
pHelper
);
// --------- For set operations
// --------- For set operations
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
int
tsdbSetAndOpenHelperFile
(
SRWHelper
*
pHelper
,
SFileGroup
*
pGroup
);
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
SHelperTable
*
pHelperTable
,
STSchema
*
pSchema
);
// void tsdbSetHelperTable(SRWHelper *pHelper, SHelperTable *pHelperTable, STSchema *pSchema);
void
tsdbSetHelperTable
(
SRWHelper
*
pHelper
,
STable
*
pTable
,
STsdbRepo
*
pRepo
);
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
);
int
tsdbCloseHelperFile
(
SRWHelper
*
pHelper
,
bool
hasError
);
// --------- For read operations
// --------- 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
...
@@ -400,6 +400,7 @@ int tsdbInitTableCfg(STableCfg *config, ETableType type, int64_t uid, int32_t ti
config
->
superUid
=
TSDB_INVALID_SUPER_TABLE_ID
;
config
->
superUid
=
TSDB_INVALID_SUPER_TABLE_ID
;
config
->
tableId
.
uid
=
uid
;
config
->
tableId
.
uid
=
uid
;
config
->
tableId
.
tid
=
tid
;
config
->
tableId
.
tid
=
tid
;
config
->
name
=
strdup
(
"test1"
);
return
0
;
return
0
;
}
}
...
@@ -873,16 +874,7 @@ static void *tsdbCommitData(void *arg) {
...
@@ -873,16 +874,7 @@ static void *tsdbCommitData(void *arg) {
return
NULL
;
return
NULL
;
}
}
// Create a write helper to commit data
if
(
tsdbInitWriteHelper
(
&
whelper
,
pRepo
)
<
0
)
goto
_exit
;
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
((
pDataCols
=
tdNewDataCols
(
pMeta
->
maxRowBytes
,
pMeta
->
maxCols
,
pCfg
->
maxRowsPerFileBlock
))
==
NULL
)
goto
_exit
;
if
((
pDataCols
=
tdNewDataCols
(
pMeta
->
maxRowBytes
,
pMeta
->
maxCols
,
pCfg
->
maxRowsPerFileBlock
))
==
NULL
)
goto
_exit
;
int
sfid
=
tsdbGetKeyFileId
(
pCache
->
imem
->
keyFirst
,
pCfg
->
daysPerFile
,
pCfg
->
precision
);
int
sfid
=
tsdbGetKeyFileId
(
pCache
->
imem
->
keyFirst
,
pCfg
->
daysPerFile
,
pCfg
->
precision
);
...
@@ -898,7 +890,6 @@ static void *tsdbCommitData(void *arg) {
...
@@ -898,7 +890,6 @@ static void *tsdbCommitData(void *arg) {
_exit:
_exit:
tdFreeDataCols
(
pDataCols
);
tdFreeDataCols
(
pDataCols
);
tsdbDestroyHelper
(
&
whelper
);
tsdbDestroyTableIters
(
iters
,
pCfg
->
maxTables
);
tsdbDestroyTableIters
(
iters
,
pCfg
->
maxTables
);
tsdbLockRepo
(
arg
);
tsdbLockRepo
(
arg
);
...
@@ -948,8 +939,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
...
@@ -948,8 +939,7 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SSkipListIterator **iters
SSkipListIterator
*
pIter
=
iters
[
tid
];
SSkipListIterator
*
pIter
=
iters
[
tid
];
// Set the helper and the buffer dataCols object to help to write this table
// 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
,
pTable
,
pRepo
);
tsdbSetHelperTable
(
pHelper
,
&
hTable
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
tdInitDataCols
(
pDataCols
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
tdInitDataCols
(
pDataCols
,
tsdbGetTableSchema
(
pMeta
,
pTable
));
// Loop to write the data in the cache to files. If no data to write, just break the loop
// 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 @@
...
@@ -18,7 +18,7 @@
#include "talgo.h"
#include "talgo.h"
// Local function definitions
// Local function definitions
static
int
tsdbCheckHelperCfg
(
SHelperCfg
*
pCfg
);
//
static int tsdbCheckHelperCfg(SHelperCfg *pCfg);
static
int
tsdbInitHelperFile
(
SRWHelper
*
pHelper
);
static
int
tsdbInitHelperFile
(
SRWHelper
*
pHelper
);
// static void tsdbClearHelperFile(SHelperFile *pHFile);
// static void tsdbClearHelperFile(SHelperFile *pHFile);
static
bool
tsdbShouldCreateNewLast
(
SRWHelper
*
pHelper
);
static
bool
tsdbShouldCreateNewLast
(
SRWHelper
*
pHelper
);
...
@@ -102,14 +102,21 @@ static void tsdbDestroyHelperBlock(SRWHelper *pHelper) {
...
@@ -102,14 +102,21 @@ static void tsdbDestroyHelperBlock(SRWHelper *pHelper) {
tdFreeDataCols
(
pHelper
->
pDataCols
[
1
]);
tdFreeDataCols
(
pHelper
->
pDataCols
[
1
]);
}
}
// ------------------------------------------ OPERATIONS FOR OUTSIDE ------------------------------------------
static
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
STsdbRepo
*
pRepo
,
tsdb_rw_helper_t
type
)
{
int
tsdbInitHelper
(
SRWHelper
*
pHelper
,
SHelperCfg
*
pCfg
)
{
if
(
pHelper
==
NULL
||
pRepo
==
NULL
)
return
-
1
;
if
(
pHelper
==
NULL
||
pCfg
==
NULL
||
tsdbCheckHelperCfg
(
pCfg
)
<
0
)
return
-
1
;
memset
((
void
*
)
pHelper
,
0
,
sizeof
(
*
pHelper
));
memset
((
void
*
)
pHelper
,
0
,
sizeof
(
*
pHelper
));
// Init global configuration
// 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
;
pHelper
->
state
=
TSDB_HELPER_CLEAR_STATE
;
// Init file part
// Init file part
...
@@ -128,6 +135,15 @@ _err:
...
@@ -128,6 +135,15 @@ _err:
return
-
1
;
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
)
{
void
tsdbDestroyHelper
(
SRWHelper
*
pHelper
)
{
if
(
pHelper
)
{
if
(
pHelper
)
{
tsdbDestroyHelperFile
(
pHelper
);
tsdbDestroyHelperFile
(
pHelper
);
...
@@ -243,18 +259,22 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
...
@@ -243,18 +259,22 @@ int tsdbCloseHelperFile(SRWHelper *pHelper, bool hasError) {
return
0
;
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
));
ASSERT
(
helperHasState
(
pHelper
,
TSDB_HELPER_FILE_SET_AND_OPEN
|
TSDB_HELPER_IDX_LOAD
));
// Clear members and state used by previous table
// Clear members and state used by previous table
tsdbResetHelperTable
(
pHelper
);
tsdbResetHelperTable
(
pHelper
);
ASSERT
(
pHelper
->
state
==
(
TSDB_HELPER_FILE_SET_AND_OPEN
|
TSDB_HELPER_IDX_LOAD
));
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
[
0
],
pSchema
);
tdInitDataCols
(
pHelper
->
pDataCols
[
1
],
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
)
{
if
(
pIdx
->
offset
>
0
&&
pIdx
->
hasLast
)
{
pHelper
->
hasOldLastBlock
=
true
;
pHelper
->
hasOldLastBlock
=
true
;
}
}
...
@@ -610,10 +630,10 @@ _err:
...
@@ -610,10 +630,10 @@ _err:
return
-
1
;
return
-
1
;
}
}
static
int
tsdbCheckHelperCfg
(
SHelperCfg
*
pCfg
)
{
//
static int tsdbCheckHelperCfg(SHelperCfg *pCfg) {
// TODO
//
// TODO
return
0
;
//
return 0;
}
//
}
// static void tsdbClearHelperFile(SHelperFile *pHFile) {
// static void tsdbClearHelperFile(SHelperFile *pHFile) {
// pHFile->fid = -1;
// pHFile->fid = -1;
...
...
src/tsdb/tests/tsdbTests.cpp
浏览文件 @
7e8fc3b2
...
@@ -191,29 +191,15 @@ TEST(TsdbTest, createRepo) {
...
@@ -191,29 +191,15 @@ TEST(TsdbTest, createRepo) {
// Read from file
// Read from file
SRWHelper
rhelper
;
SRWHelper
rhelper
;
SHelperCfg
helperCfg
=
{
tsdbInitReadHelper
(
&
rhelper
,
repo
);
.
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
);
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
repo
->
tsdbFileH
,
1833
);
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
repo
->
tsdbFileH
,
1833
);
ASSERT_NE
(
pFGroup
,
nullptr
);
ASSERT_NE
(
pFGroup
,
nullptr
);
ASSERT_GE
(
tsdbSetAndOpenHelperFile
(
&
rhelper
,
pFGroup
),
0
);
ASSERT_GE
(
tsdbSetAndOpenHelperFile
(
&
rhelper
,
pFGroup
),
0
);
SHelperTable
htable
=
{
STable
*
pTable
=
tsdbGetTableByUid
(
repo
->
tsdbMeta
,
tCfg
.
tableId
.
uid
);
.
uid
=
tCfg
.
tableId
.
uid
,
ASSERT_NE
(
pTable
,
nullptr
);
.
tid
=
tCfg
.
tableId
.
tid
,
tsdbSetHelperTable
(
&
rhelper
,
pTable
,
repo
);
.
sversion
=
tCfg
.
sversion
};
tsdbSetHelperTable
(
&
rhelper
,
&
htable
,
schema
);
ASSERT_EQ
(
tsdbLoadCompInfo
(
&
rhelper
,
NULL
),
0
);
ASSERT_EQ
(
tsdbLoadCompInfo
(
&
rhelper
,
NULL
),
0
);
ASSERT_EQ
(
tsdbLoadBlockData
(
&
rhelper
,
0
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录