Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
cca6f87a
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看板
提交
cca6f87a
编写于
6月 11, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
53cc3945
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
144 addition
and
159 deletion
+144
-159
src/inc/tsdb.h
src/inc/tsdb.h
+24
-34
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+0
-118
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+119
-2
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+1
-5
未找到文件。
src/inc/tsdb.h
浏览文件 @
cca6f87a
...
...
@@ -19,11 +19,11 @@
#include <stdbool.h>
#include <stdint.h>
#include "tdataformat.h"
#include "tname.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tdataformat.h"
#include "tname.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -35,7 +35,7 @@ extern "C" {
#define TSDB_INVALID_SUPER_TABLE_ID -1
#define TSDB_STATUS_COMMIT_START 1
#define TSDB_STATUS_COMMIT_OVER
2
#define TSDB_STATUS_COMMIT_OVER 2
// --------- TSDB APPLICATION HANDLE DEFINITION
typedef
struct
{
...
...
@@ -53,9 +53,9 @@ typedef struct {
int32_t
tsdbId
;
int32_t
cacheBlockSize
;
int32_t
totalBlocks
;
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
keep
;
// day of data to keep
int32_t
maxTables
;
// maximum number of tables this repository can have
int32_t
daysPerFile
;
// day per file sharding policy
int32_t
keep
;
// day of data to keep
int32_t
keep1
;
int32_t
keep2
;
int32_t
minRowsPerFileBlock
;
// minimum rows per file block
...
...
@@ -74,17 +74,14 @@ typedef struct {
typedef
void
TSDB_REPO_T
;
// use void to hide implementation details from outside
void
tsdbSetDefaultCfg
(
STsdbCfg
*
pCfg
);
STsdbCfg
*
tsdbCreateDefaultCfg
();
void
tsdbFreeCfg
(
STsdbCfg
*
pCfg
);
STsdbCfg
*
tsdbGetCfg
(
const
TSDB_REPO_T
*
repo
);
// --------- TSDB REPOSITORY DEFINITION
int
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
TSDB_REPO_T
*
repo
);
int
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
,
void
*
limiter
);
int32_t
tsdbDropRepo
(
TSDB_REPO_T
*
repo
);
TSDB_REPO_T
*
tsdbOpenRepo
(
char
*
rootDir
,
STsdbAppH
*
pAppH
);
int32_t
tsdbCloseRepo
(
TSDB_REPO_T
*
repo
,
int
toCommit
);
int32_t
tsdbConfigRepo
(
TSDB_REPO_T
*
repo
,
STsdbCfg
*
pCfg
);
int32_t
tsdbCloseRepo
(
TSDB_REPO_T
*
repo
,
int
toCommit
);
int32_t
tsdbConfigRepo
(
TSDB_REPO_T
*
repo
,
STsdbCfg
*
pCfg
);
// --------- TSDB TABLE DEFINITION
typedef
struct
{
...
...
@@ -106,23 +103,14 @@ typedef struct {
char
*
sql
;
}
STableCfg
;
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
uint64_t
uid
,
int32_t
tid
);
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
uint64_t
uid
);
int
tsdbTableSetSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
int
tsdbTableSetTagValue
(
STableCfg
*
config
,
SKVRow
row
,
bool
dup
);
int
tsdbTableSetName
(
STableCfg
*
config
,
char
*
name
,
bool
dup
);
int
tsdbTableSetSName
(
STableCfg
*
config
,
char
*
sname
,
bool
dup
);
int
tsdbTableSetStreamSql
(
STableCfg
*
config
,
char
*
sql
,
bool
dup
);
void
tsdbClearTableCfg
(
STableCfg
*
config
);
void
*
tsdbGetTableTagVal
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
,
int32_t
colId
,
int16_t
type
,
int16_t
bytes
);
char
*
tsdbGetTableName
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
);
void
*
tsdbGetTableTagVal
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
,
int32_t
colId
,
int16_t
type
,
int16_t
bytes
);
char
*
tsdbGetTableName
(
TSDB_REPO_T
*
repo
,
const
STableId
*
id
);
STableCfg
*
tsdbCreateTableCfgFromMsg
(
SMDCreateTableMsg
*
pMsg
);
int
tsdbCreateTable
(
TSDB_REPO_T
*
repo
,
STableCfg
*
pCfg
);
int
tsdbDropTable
(
TSDB_REPO_T
*
pRepo
,
STableId
tableId
);
int
tsdbAlterTable
(
TSDB_REPO_T
*
repo
,
STableCfg
*
pCfg
);
int
tsdbUpdateTagValue
(
TSDB_REPO_T
*
repo
,
SUpdateTableTagValMsg
*
pMsg
);
TSKEY
tsdbGetTableLastKey
(
TSDB_REPO_T
*
repo
,
uint64_t
uid
);
void
tsdbStartStream
(
TSDB_REPO_T
*
repo
);
...
...
@@ -156,7 +144,7 @@ STableInfo *tsdbGetTableInfo(TSDB_REPO_T *pRepo, STableId tid);
*
* @return the number of points inserted, -1 for failure and the error number is set
*/
int32_t
tsdbInsertData
(
TSDB_REPO_T
*
repo
,
SSubmitMsg
*
pMsg
,
SShellSubmitRspMsg
*
pRsp
)
;
int32_t
tsdbInsertData
(
TSDB_REPO_T
*
repo
,
SSubmitMsg
*
pMsg
,
SShellSubmitRspMsg
*
pRsp
)
;
// -- FOR QUERY TIME SERIES DATA
...
...
@@ -164,10 +152,10 @@ typedef void *TsdbQueryHandleT; // Use void to hide implementation details
// query condition to build vnode iterator
typedef
struct
STsdbQueryCond
{
STimeWindow
twindow
;
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
numOfCols
;
SColumnInfo
*
colList
;
STimeWindow
twindow
;
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
numOfCols
;
SColumnInfo
*
colList
;
}
STsdbQueryCond
;
typedef
struct
SDataBlockInfo
{
...
...
@@ -199,7 +187,7 @@ typedef void *TsdbPosT;
* @param qinfo query info handle from query processor
* @return
*/
TsdbQueryHandleT
*
tsdbQueryTables
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
TsdbQueryHandleT
*
tsdbQueryTables
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
/**
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
...
...
@@ -207,15 +195,17 @@ TsdbQueryHandleT *tsdbQueryTables(TSDB_REPO_T *tsdb, STsdbQueryCond *pCond, STab
* all tables in this group.
*
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param pCond query condition, including time window, result set order, and basic required columns for each
* block
* @param groupInfo tableId list.
* @return
*/
TsdbQueryHandleT
tsdbQueryLastRow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
TsdbQueryHandleT
tsdbQueryLastRow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupInfo
,
void
*
qinfo
);
SArray
*
tsdbGetQueriedTableIdList
(
TsdbQueryHandleT
*
pHandle
);
SArray
*
tsdbGetQueriedTableIdList
(
TsdbQueryHandleT
*
pHandle
);
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
);
TsdbQueryHandleT
tsdbQueryRowsInExternalWindow
(
TSDB_REPO_T
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
void
*
qinfo
);
/**
* move to next block if exists
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
cca6f87a
...
...
@@ -404,11 +404,6 @@ STsdbRepoInfo *tsdbGetStatus(TSDB_REPO_T *pRepo) {
return
NULL
;
}
int
tsdbAlterTable
(
TSDB_REPO_T
*
pRepo
,
STableCfg
*
pCfg
)
{
// TODO
return
0
;
}
int
tsdbUpdateTagValue
(
TSDB_REPO_T
*
repo
,
SUpdateTableTagValMsg
*
pMsg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
...
...
@@ -511,119 +506,6 @@ int32_t tsdbInsertData(TSDB_REPO_T *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *
return
code
;
}
/**
* Initialize a table configuration
*/
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
uint64_t
uid
,
int32_t
tid
)
{
if
(
config
==
NULL
)
return
-
1
;
if
(
type
!=
TSDB_CHILD_TABLE
&&
type
!=
TSDB_NORMAL_TABLE
&&
type
!=
TSDB_STREAM_TABLE
)
return
-
1
;
memset
((
void
*
)
config
,
0
,
sizeof
(
STableCfg
));
config
->
type
=
type
;
config
->
superUid
=
TSDB_INVALID_SUPER_TABLE_ID
;
config
->
tableId
.
uid
=
uid
;
config
->
tableId
.
tid
=
tid
;
config
->
name
=
NULL
;
config
->
sql
=
NULL
;
return
0
;
}
/**
* Set the super table UID of the created table
*/
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
uint64_t
uid
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
uid
==
TSDB_INVALID_SUPER_TABLE_ID
)
return
-
1
;
config
->
superUid
=
uid
;
return
0
;
}
/**
* Set the table schema in the configuration
* @param config the configuration to set
* @param pSchema the schema to set
* @param dup use the schema directly or duplicate one for use
*
* @return 0 for success and -1 for failure
*/
int
tsdbTableSetSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
)
{
if
(
dup
)
{
config
->
schema
=
tdDupSchema
(
pSchema
);
}
else
{
config
->
schema
=
pSchema
;
}
return
0
;
}
/**
* Set the table schema in the configuration
* @param config the configuration to set
* @param pSchema the schema to set
* @param dup use the schema directly or duplicate one for use
*
* @return 0 for success and -1 for failure
*/
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagSchema
=
tdDupSchema
(
pSchema
);
}
else
{
config
->
tagSchema
=
pSchema
;
}
return
0
;
}
int
tsdbTableSetTagValue
(
STableCfg
*
config
,
SKVRow
row
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagValues
=
tdKVRowDup
(
row
);
}
else
{
config
->
tagValues
=
row
;
}
return
0
;
}
int
tsdbTableSetName
(
STableCfg
*
config
,
char
*
name
,
bool
dup
)
{
if
(
dup
)
{
config
->
name
=
strdup
(
name
);
if
(
config
->
name
==
NULL
)
return
-
1
;
}
else
{
config
->
name
=
name
;
}
return
0
;
}
int
tsdbTableSetSName
(
STableCfg
*
config
,
char
*
sname
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
sname
=
strdup
(
sname
);
if
(
config
->
sname
==
NULL
)
return
-
1
;
}
else
{
config
->
sname
=
sname
;
}
return
0
;
}
int
tsdbTableSetStreamSql
(
STableCfg
*
config
,
char
*
sql
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_STREAM_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
sql
=
strdup
(
sql
);
if
(
config
->
sql
==
NULL
)
return
-
1
;
}
else
{
config
->
sql
=
sql
;
}
return
0
;
}
void
tsdbClearTableCfg
(
STableCfg
*
config
)
{
if
(
config
)
{
if
(
config
->
schema
)
tdFreeSchema
(
config
->
schema
);
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
cca6f87a
...
...
@@ -8,11 +8,18 @@
#define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here
// #define TSDB_META_FILE_NAME "META"
static
int
tsdbFreeTable
(
STable
*
pTable
);
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
);
static
int
tsdbAddTableToMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
,
bool
addIdx
);
static
int
tsdbRemoveTableFromMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
,
bool
rmFromIdx
);
static
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
uint64_t
uid
,
int32_t
tid
);
static
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
uint64_t
uid
);
static
int
tsdbTableSetSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
static
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
);
static
int
tsdbTableSetTagValue
(
STableCfg
*
config
,
SKVRow
row
,
bool
dup
);
static
int
tsdbTableSetName
(
STableCfg
*
config
,
char
*
name
,
bool
dup
);
static
int
tsdbTableSetSName
(
STableCfg
*
config
,
char
*
sname
,
bool
dup
);
static
int
tsdbTableSetStreamSql
(
STableCfg
*
config
,
char
*
sql
,
bool
dup
);
/**
* Encode a TSDB table object as a binary content
...
...
@@ -796,4 +803,114 @@ int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
char
*
getTSTupleKey
(
const
void
*
data
)
{
SDataRow
row
=
(
SDataRow
)
data
;
return
POINTER_SHIFT
(
row
,
TD_DATA_ROW_HEAD_SIZE
);
}
\ No newline at end of file
}
static
int
tsdbInitTableCfg
(
STableCfg
*
config
,
ETableType
type
,
uint64_t
uid
,
int32_t
tid
)
{
if
(
config
==
NULL
)
return
-
1
;
if
(
type
!=
TSDB_CHILD_TABLE
&&
type
!=
TSDB_NORMAL_TABLE
&&
type
!=
TSDB_STREAM_TABLE
)
return
-
1
;
memset
((
void
*
)
config
,
0
,
sizeof
(
STableCfg
));
config
->
type
=
type
;
config
->
superUid
=
TSDB_INVALID_SUPER_TABLE_ID
;
config
->
tableId
.
uid
=
uid
;
config
->
tableId
.
tid
=
tid
;
config
->
name
=
NULL
;
config
->
sql
=
NULL
;
return
0
;
}
/**
* Set the super table UID of the created table
*/
static
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
uint64_t
uid
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
uid
==
TSDB_INVALID_SUPER_TABLE_ID
)
return
-
1
;
config
->
superUid
=
uid
;
return
0
;
}
/**
* Set the table schema in the configuration
* @param config the configuration to set
* @param pSchema the schema to set
* @param dup use the schema directly or duplicate one for use
*
* @return 0 for success and -1 for failure
*/
static
int
tsdbTableSetSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
)
{
if
(
dup
)
{
config
->
schema
=
tdDupSchema
(
pSchema
);
}
else
{
config
->
schema
=
pSchema
;
}
return
0
;
}
/**
* Set the table schema in the configuration
* @param config the configuration to set
* @param pSchema the schema to set
* @param dup use the schema directly or duplicate one for use
*
* @return 0 for success and -1 for failure
*/
static
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagSchema
=
tdDupSchema
(
pSchema
);
}
else
{
config
->
tagSchema
=
pSchema
;
}
return
0
;
}
static
int
tsdbTableSetTagValue
(
STableCfg
*
config
,
SKVRow
row
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagValues
=
tdKVRowDup
(
row
);
}
else
{
config
->
tagValues
=
row
;
}
return
0
;
}
static
int
tsdbTableSetName
(
STableCfg
*
config
,
char
*
name
,
bool
dup
)
{
if
(
dup
)
{
config
->
name
=
strdup
(
name
);
if
(
config
->
name
==
NULL
)
return
-
1
;
}
else
{
config
->
name
=
name
;
}
return
0
;
}
static
int
tsdbTableSetSName
(
STableCfg
*
config
,
char
*
sname
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_CHILD_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
sname
=
strdup
(
sname
);
if
(
config
->
sname
==
NULL
)
return
-
1
;
}
else
{
config
->
sname
=
sname
;
}
return
0
;
}
static
int
tsdbTableSetStreamSql
(
STableCfg
*
config
,
char
*
sql
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_STREAM_TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
sql
=
strdup
(
sql
);
if
(
config
->
sql
==
NULL
)
return
-
1
;
}
else
{
config
->
sql
=
sql
;
}
return
0
;
}
src/vnode/src/vnodeWrite.c
浏览文件 @
cca6f87a
...
...
@@ -131,11 +131,7 @@ static int32_t vnodeProcessDropTableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
}
static
int32_t
vnodeProcessAlterTableMsg
(
SVnodeObj
*
pVnode
,
void
*
pCont
,
SRspRet
*
pRet
)
{
STableCfg
*
pCfg
=
tsdbCreateTableCfgFromMsg
((
SMDCreateTableMsg
*
)
pCont
);
if
(
pCfg
==
NULL
)
return
terrno
;
int32_t
code
=
tsdbAlterTable
(
pVnode
->
tsdb
,
pCfg
);
tsdbClearTableCfg
(
pCfg
);
return
code
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
vnodeProcessDropStableMsg
(
SVnodeObj
*
pVnode
,
void
*
pCont
,
SRspRet
*
pRet
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录