Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
cc4d5078
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
cc4d5078
编写于
3月 14, 2020
作者:
H
hzcheng
提交者:
GitHub
3月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1370 from taosdata/refact/slguan
[TD-10]
上级
e54e1bae
419a0610
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
180 addition
and
136 deletion
+180
-136
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-2
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+2
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-2
src/common/inc/dataformat.h
src/common/inc/dataformat.h
+0
-1
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+37
-19
src/dnode/src/dnodeWrite.c
src/dnode/src/dnodeWrite.c
+70
-45
src/inc/taosdef.h
src/inc/taosdef.h
+14
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+0
-1
src/mnode/CMakeLists.txt
src/mnode/CMakeLists.txt
+1
-0
src/mnode/src/mgmtNormalTable.c
src/mnode/src/mgmtNormalTable.c
+19
-24
src/mnode/src/mgmtSuperTable.c
src/mnode/src/mgmtSuperTable.c
+1
-1
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+16
-16
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+0
-7
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+1
-1
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+4
-4
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+10
-10
src/vnode/tsdb/tests/tsdbTests.cpp
src/vnode/tsdb/tests/tsdbTests.cpp
+1
-1
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
cc4d5078
...
...
@@ -30,10 +30,10 @@ extern "C" {
#include "taosdef.h"
#define UTIL_METER_IS_SUPERTABLE(metaInfo) \
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_
TABLE_TYPE_
SUPER_TABLE))
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_SUPER_TABLE))
#define UTIL_METER_IS_NOMRAL_METER(metaInfo) (!(UTIL_METER_IS_SUPERTABLE(metaInfo)))
#define UTIL_METER_IS_CREATE_FROM_METRIC(metaInfo) \
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_
TABLE_TYPE_
CHILD_TABLE))
(((metaInfo)->pMeterMeta != NULL) && ((metaInfo)->pMeterMeta->tableType == TSDB_CHILD_TABLE))
#define TSDB_COL_IS_TAG(f) (((f)&TSDB_COL_TAG) != 0)
...
...
src/client/src/tscLocal.c
浏览文件 @
cc4d5078
...
...
@@ -79,8 +79,8 @@ static int32_t getToStringLength(const char *pData, int32_t length, int32_t type
static
int32_t
tscMaxLengthOfTagsFields
(
SSqlObj
*
pSql
)
{
STableMeta
*
pMeta
=
tscGetMeterMetaInfo
(
&
pSql
->
cmd
,
0
,
0
)
->
pMeterMeta
;
if
(
pMeta
->
tableType
==
TSDB_
TABLE_TYPE_SUPER_TABLE
||
pMeta
->
tableType
==
TSDB_TABLE_TYPE
_NORMAL_TABLE
||
pMeta
->
tableType
==
TSDB_
TABLE_TYPE_
STREAM_TABLE
)
{
if
(
pMeta
->
tableType
==
TSDB_
SUPER_TABLE
||
pMeta
->
tableType
==
TSDB
_NORMAL_TABLE
||
pMeta
->
tableType
==
TSDB_STREAM_TABLE
)
{
return
0
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
cc4d5078
...
...
@@ -2624,7 +2624,7 @@ int tscProcessMeterMetaRsp(SSqlObj *pSql) {
// int32_t tagLen = 0;
// SSchema *pTagsSchema = tsGetTagSchema(pMeta);
//
// if (pMeta->tableType == TSDB_
TABLE_TYPE_
CHILD_TABLE) {
// if (pMeta->tableType == TSDB_CHILD_TABLE) {
// for (int32_t i = 0; i < pMeta->numOfTags; ++i) {
// tagLen += pTagsSchema[i].bytes;
// }
...
...
@@ -2739,7 +2739,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
int32_t
tagLen
=
0
;
SSchema
*
pTagsSchema
=
tsGetTagSchema
(
pMeta
);
if
(
pMeta
->
tableType
==
TSDB_
TABLE_TYPE_
CHILD_TABLE
)
{
if
(
pMeta
->
tableType
==
TSDB_CHILD_TABLE
)
{
for
(
int32_t
j
=
0
;
j
<
pMeta
->
numOfTags
;
++
j
)
{
tagLen
+=
pTagsSchema
[
j
].
bytes
;
}
...
...
src/common/inc/dataformat.h
浏览文件 @
cc4d5078
...
...
@@ -21,7 +21,6 @@
#include "taosdef.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
cc4d5078
...
...
@@ -87,18 +87,7 @@ int32_t dnodeInitMgmt() {
cfg
.
cfg
.
maxSessions
=
1000
;
cfg
.
cfg
.
daysPerFile
=
10
;
dnodeCreateVnode
(
&
cfg
);
SVnodeObj
*
pVnode
=
dnodeGetVnode
(
cfg
.
cfg
.
vgId
);
dnodeDropVnode
(
pVnode
);
// dnodeCreateVnode(&cfg);
// SVnodeObj *pVnode = dnodeGetVnode(cfg.cfg.vgId);
// dnodeCleanupVnodes();
dnodeOpenVnodes
();
dnodeCleanupVnodes
();
//return dnodeOpenVnodes();
return
dnodeOpenVnodes
();
}
void
dnodeCleanupMgmt
()
{
...
...
@@ -182,9 +171,9 @@ static int32_t dnodeOpenVnodes() {
int32_t
vnode
=
atoi
(
de
->
d_name
+
5
);
if
(
vnode
==
0
)
continue
;
char
tsdb
Dir
[
TSDB_FILENAME_LEN
];
sprintf
(
tsdb
Dir
,
"%s/%s"
,
tsVnodeDir
,
de
->
d_name
);
int32_t
code
=
dnodeOpenVnode
(
vnode
,
tsdb
Dir
);
char
vnode
Dir
[
TSDB_FILENAME_LEN
];
sprintf
(
vnode
Dir
,
"%s/%s"
,
tsVnodeDir
,
de
->
d_name
);
int32_t
code
=
dnodeOpenVnode
(
vnode
,
vnode
Dir
);
if
(
code
==
0
)
{
numOfVnodes
++
;
}
...
...
@@ -203,9 +192,11 @@ static void dnodeCleanupVnodes() {
}
static
int32_t
dnodeOpenVnode
(
int32_t
vnode
,
char
*
rootDir
)
{
void
*
pTsdb
=
tsdbOpenRepo
(
rootDir
);
char
tsdbDir
[
TSDB_FILENAME_LEN
];
sprintf
(
tsdbDir
,
"%s/tsdb"
,
rootDir
);
void
*
pTsdb
=
tsdbOpenRepo
(
tsdbDir
);
if
(
pTsdb
==
NULL
)
{
dError
(
"failed to open
vnode:%d in dir:%s, reason:%s"
,
vnode
,
root
Dir
,
tstrerror
(
terrno
));
dError
(
"failed to open
tsdb in vnode:%d %s, reason:%s"
,
vnode
,
tsdb
Dir
,
tstrerror
(
terrno
));
return
terrno
;
}
...
...
@@ -260,7 +251,7 @@ static void dnodeCleanupVnode(SVnodeObj *pVnode) {
}
static
int32_t
dnodeCreateVnode
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
STsdbCfg
tsdbCfg
;
STsdbCfg
tsdbCfg
=
{
0
}
;
tsdbCfg
.
vgId
=
pVnodeCfg
->
cfg
.
vgId
;
tsdbCfg
.
precision
=
pVnodeCfg
->
cfg
.
precision
;
tsdbCfg
.
tsdbId
=
pVnodeCfg
->
vnode
;
...
...
@@ -273,9 +264,32 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
char
rootDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
rootDir
,
"%s/vnode%d"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
if
(
mkdir
(
rootDir
,
0755
)
!=
0
)
{
if
(
errno
==
EACCES
)
{
return
TSDB_CODE_NO_DISK_PERMISSIONS
;
}
else
if
(
errno
==
ENOSPC
)
{
return
TSDB_CODE_SERV_NO_DISKSPACE
;
}
else
if
(
errno
==
EEXIST
)
{
}
else
{
return
TSDB_CODE_VG_INIT_FAILED
;
}
}
sprintf
(
rootDir
,
"%s/vnode%d/tsdb"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
if
(
mkdir
(
rootDir
,
0755
)
!=
0
)
{
if
(
errno
==
EACCES
)
{
return
TSDB_CODE_NO_DISK_PERMISSIONS
;
}
else
if
(
errno
==
ENOSPC
)
{
return
TSDB_CODE_SERV_NO_DISKSPACE
;
}
else
if
(
errno
==
EEXIST
)
{
}
else
{
return
TSDB_CODE_VG_INIT_FAILED
;
}
}
void
*
pTsdb
=
tsdbCreateRepo
(
rootDir
,
&
tsdbCfg
,
NULL
);
if
(
pTsdb
==
NULL
)
{
dError
(
"failed to create tsdb in vnode:%d, reason:%s"
,
pVnodeCfg
->
vnode
,
tstrerror
(
terrno
));
return
terrno
;
}
...
...
@@ -295,6 +309,7 @@ static int32_t dnodeCreateVnode(SMDCreateVnodeMsg *pVnodeCfg) {
taosAddIntHash
(
tsDnodeVnodesHash
,
vnodeObj
.
vgId
,
(
char
*
)
(
&
vnodeObj
));
dPrint
(
"vnode:%d is created"
,
pVnodeCfg
->
vnode
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -324,13 +339,16 @@ static void dnodeProcessCreateVnodeMsg(SRpcMsg *rpcMsg) {
pCreate
->
cfg
.
maxSessions
=
htonl
(
pCreate
->
cfg
.
maxSessions
);
pCreate
->
cfg
.
daysPerFile
=
htonl
(
pCreate
->
cfg
.
daysPerFile
);
dTrace
(
"start to create vnode:%d"
,
pCreate
->
vnode
);
SVnodeObj
*
pVnodeObj
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pCreate
->
cfg
.
vgId
);
if
(
pVnodeObj
!=
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
dPrint
(
"vnode:%d is already exist"
,
pCreate
->
vnode
);
}
else
{
rpcRsp
.
code
=
dnodeCreateVnode
(
pCreate
);
}
rpcRsp
.
code
=
TSDB_CODE_SUCCESS
;
rpcSendResponse
(
&
rpcRsp
);
}
...
...
src/dnode/src/dnodeWrite.c
浏览文件 @
cc4d5078
...
...
@@ -20,6 +20,8 @@
#include "tlog.h"
#include "tqueue.h"
#include "trpc.h"
#include "tsdb.h"
#include "dataformat.h"
#include "dnodeWrite.h"
#include "dnodeMgmt.h"
...
...
@@ -106,13 +108,13 @@ void dnodeWrite(SRpcMsg *pMsg) {
while
(
leftLen
>
0
)
{
SWriteMsgHead
*
pHead
=
(
SWriteMsgHead
*
)
pCont
;
int32_t
vgId
=
htonl
(
pHead
->
vgId
);
int32_t
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
pHead
->
vgId
);
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
void
*
pVnode
=
dnodeGetVnode
(
vgId
);
void
*
pVnode
=
dnodeGetVnode
(
pHead
->
vgId
);
if
(
pVnode
==
NULL
)
{
leftLen
-=
contLen
;
pCont
-=
contLen
;
leftLen
-=
pHead
->
contLen
;
pCont
-=
pHead
->
contLen
;
continue
;
}
...
...
@@ -120,7 +122,7 @@ void dnodeWrite(SRpcMsg *pMsg) {
SWriteMsg
writeMsg
;
writeMsg
.
rpcMsg
=
*
pMsg
;
writeMsg
.
pCont
=
pCont
;
writeMsg
.
contLen
=
contLen
;
writeMsg
.
contLen
=
pHead
->
contLen
;
writeMsg
.
pRpcContext
=
pRpcContext
;
writeMsg
.
pVnode
=
pVnode
;
// pVnode shall be saved for usage later
...
...
@@ -128,8 +130,8 @@ void dnodeWrite(SRpcMsg *pMsg) {
taosWriteQitem
(
queue
,
&
writeMsg
);
// next vnode
leftLen
-=
contLen
;
pCont
-=
contLen
;
leftLen
-=
pHead
->
contLen
;
pCont
-=
pHead
->
contLen
;
queuedMsgNum
++
;
}
...
...
@@ -148,7 +150,7 @@ void dnodeWrite(SRpcMsg *pMsg) {
void
*
dnodeAllocateWriteWorker
()
{
SWriteWorker
*
pWorker
=
wWorkerPool
.
writeWorker
+
wWorkerPool
.
nextId
;
taos_queue
*
queue
=
taosOpenQueue
(
sizeof
(
SWriteMsg
));
if
(
queue
!=
NULL
)
return
queue
;
if
(
queue
==
NULL
)
return
NULL
;
if
(
pWorker
->
qset
==
NULL
)
{
pWorker
->
qset
=
taosOpenQset
();
...
...
@@ -289,45 +291,68 @@ static void dnodeProcessSubmitMsg(SWriteMsg *pMsg) {
static
void
dnodeProcessCreateTableMsg
(
SWriteMsg
*
pMsg
)
{
SMDCreateTableMsg
*
pTable
=
pMsg
->
rpcMsg
.
pCont
;
if
(
pTable
->
tableType
==
TSDB_TABLE_TYPE_CHILD_TABLE
)
{
dTrace
(
"table:%s, start to create child table, stable:%s"
,
pTable
->
tableId
,
pTable
->
superTableId
);
}
else
if
(
pTable
->
tableType
==
TSDB_TABLE_TYPE_NORMAL_TABLE
){
dTrace
(
"table:%s, start to create normal table"
,
pTable
->
tableId
);
}
else
if
(
pTable
->
tableType
==
TSDB_TABLE_TYPE_STREAM_TABLE
){
dTrace
(
"table:%s, start to create stream table"
,
pTable
->
tableId
);
}
else
{
dError
(
"table:%s, invalid table type:%d"
,
pTable
->
tableType
);
dTrace
(
"start to create table:%s in vgroup:%d"
,
pTable
->
tableId
,
pTable
->
vgId
);
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
void
*
pVnode
=
dnodeGetVnode
(
pTable
->
vgId
);
if
(
pVnode
==
NULL
)
{
rpcRsp
.
code
=
TSDB_CODE_INVALID_VGROUP_ID
;
dTrace
(
"failed to create table:%s in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
return
;
}
// pTable->numOfColumns = htons(pTable->numOfColumns);
// pTable->numOfTags = htons(pTable->numOfTags);
// pTable->sid = htonl(pTable->sid);
// pTable->sversion = htonl(pTable->sversion);
// pTable->tagDataLen = htonl(pTable->tagDataLen);
// pTable->sqlDataLen = htonl(pTable->sqlDataLen);
// pTable->contLen = htonl(pTable->contLen);
// pTable->numOfVPeers = htonl(pTable->numOfVPeers);
// pTable->uid = htobe64(pTable->uid);
// pTable->superTableUid = htobe64(pTable->superTableUid);
// pTable->createdTime = htobe64(pTable->createdTime);
//
// for (int i = 0; i < pTable->numOfVPeers; ++i) {
// pTable->vpeerDesc[i].ip = htonl(pTable->vpeerDesc[i].ip);
// pTable->vpeerDesc[i].vnode = htonl(pTable->vpeerDesc[i].vnode);
// }
//
// int32_t totalCols = pTable->numOfColumns + pTable->numOfTags;
// SSchema *pSchema = (SSchema *) pTable->data;
// for (int32_t col = 0; col < totalCols; ++col) {
// pSchema->bytes = htons(pSchema->bytes);
// pSchema->colId = htons(pSchema->colId);
// pSchema++;
// }
//
// int32_t code = dnodeCreateTable(pTable);
void
*
pTsdb
=
dnodeGetVnodeTsdb
(
pVnode
);
if
(
pTsdb
==
NULL
)
{
dnodeReleaseVnode
(
pVnode
);
rpcRsp
.
code
=
TSDB_CODE_NOT_ACTIVE_VNODE
;
dTrace
(
"failed to create table:%s in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
return
;
}
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
rpcMsg
.
handle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
rpcSendResponse
(
&
rpcRsp
);
pTable
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pTable
->
numOfTags
=
htons
(
pTable
->
numOfTags
);
pTable
->
sid
=
htonl
(
pTable
->
sid
);
pTable
->
sversion
=
htonl
(
pTable
->
sversion
);
pTable
->
tagDataLen
=
htonl
(
pTable
->
tagDataLen
);
pTable
->
sqlDataLen
=
htonl
(
pTable
->
sqlDataLen
);
pTable
->
uid
=
htobe64
(
pTable
->
uid
);
pTable
->
superTableUid
=
htobe64
(
pTable
->
superTableUid
);
pTable
->
createdTime
=
htobe64
(
pTable
->
createdTime
);
SSchema
*
pSchema
=
(
SSchema
*
)
pTable
->
data
;
STableCfg
tCfg
;
tsdbInitTableCfg
(
&
tCfg
,
pTable
->
tableType
,
pTable
->
uid
,
pTable
->
sid
);
STSchema
*
pDestSchema
=
tdNewSchema
(
pTable
->
numOfColumns
);
for
(
int
i
=
0
;
i
<
pTable
->
numOfColumns
;
i
++
)
{
tdSchemaAppendCol
(
pDestSchema
,
pSchema
[
i
].
type
,
htons
(
pSchema
[
i
].
colId
),
htons
(
pSchema
[
i
].
bytes
));
}
tsdbTableSetSchema
(
&
tCfg
,
pDestSchema
,
false
);
if
(
pTable
->
numOfTags
!=
NULL
)
{
STSchema
*
pDestTagSchema
=
tdNewSchema
(
pTable
->
numOfTags
);
for
(
int
i
=
pTable
->
numOfColumns
;
i
<
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
i
++
)
{
tdSchemaAppendCol
(
pDestTagSchema
,
pSchema
[
i
].
type
,
htons
(
pSchema
[
i
].
colId
),
htons
(
pSchema
[
i
].
bytes
));
}
tsdbTableSetSchema
(
&
tCfg
,
pDestTagSchema
,
false
);
}
if
(
pTable
->
tableType
==
TSDB_CHILD_TABLE
)
{
// TODO: add data row
}
rpcRsp
.
code
=
tsdbCreateTable
(
pTsdb
,
&
tCfg
);
dnodeReleaseVnode
(
pVnode
);
if
(
rpcRsp
.
code
!=
TSDB_CODE_SUCCESS
)
{
dError
(
"failed to create table:%s in vgroup:%d, reason:%s"
,
pTable
->
tableId
,
pTable
->
vgId
,
tstrerror
(
rpcRsp
.
code
));
rpcSendResponse
(
&
rpcRsp
);
}
else
{
dTrace
(
"create table:%s in vgroup:%d finished"
,
pTable
->
tableId
,
pTable
->
vgId
);
rpcSendResponse
(
&
rpcRsp
);
}
}
static
void
dnodeProcessDropTableMsg
(
SWriteMsg
*
pMsg
)
{
...
...
src/inc/taosdef.h
浏览文件 @
cc4d5078
...
...
@@ -297,6 +297,20 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_SESSIONS_PER_VNODE (300)
#define TSDB_SESSIONS_PER_DNODE (TSDB_SESSIONS_PER_VNODE * TSDB_MAX_VNODES)
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
typedef
enum
{
TSDB_SUPER_TABLE
=
0
,
// super table
TSDB_CHILD_TABLE
=
1
,
// table created from super table
TSDB_NORMAL_TABLE
=
2
,
// ordinary table
TSDB_STREAM_TABLE
=
3
,
// table created from stream computing
TSDB_TABLE_MAX
=
4
}
TSDB_TABLE_TYPE
;
#ifdef __cplusplus
}
#endif
...
...
src/inc/taosmsg.h
浏览文件 @
cc4d5078
...
...
@@ -251,7 +251,6 @@ typedef struct {
typedef
struct
{
int32_t
contLen
;
int32_t
vgId
;
int8_t
tableType
;
int16_t
numOfColumns
;
int16_t
numOfTags
;
...
...
src/mnode/CMakeLists.txt
浏览文件 @
cc4d5078
...
...
@@ -4,6 +4,7 @@ PROJECT(TDengine)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
INCLUDE_DIRECTORIES
(
${
TD_OS_DIR
}
/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/dnode/inc
)
...
...
src/mnode/src/mgmtNormalTable.c
浏览文件 @
cc4d5078
...
...
@@ -291,31 +291,26 @@ static void *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable, SVgObj *pVgr
int32_t
totalCols
=
pTable
->
numOfColumns
;
int32_t
contLen
=
sizeof
(
SMDCreateTableMsg
)
+
totalCols
*
sizeof
(
SSchema
)
+
pTable
->
sqlLen
;
SMDCreateTableMsg
*
pCreate
Table
=
rpcMallocCont
(
contLen
);
if
(
pCreate
Table
==
NULL
)
{
SMDCreateTableMsg
*
pCreate
=
rpcMallocCont
(
contLen
);
if
(
pCreate
==
NULL
)
{
return
NULL
;
}
memcpy
(
pCreateTable
->
tableId
,
pTable
->
tableId
,
TSDB_TABLE_ID_LEN
);
pCreateTable
->
tableType
=
pTable
->
type
;
pCreateTable
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pCreateTable
->
numOfTags
=
htons
(
0
);
pCreateTable
->
sid
=
htonl
(
pTable
->
sid
);
pCreateTable
->
sversion
=
htonl
(
pTable
->
sversion
);
pCreateTable
->
tagDataLen
=
htonl
(
0
);
pCreateTable
->
sqlDataLen
=
htonl
(
pTable
->
sqlLen
);
pCreateTable
->
contLen
=
htonl
(
contLen
);
pCreateTable
->
numOfVPeers
=
htonl
(
pVgroup
->
numOfVnodes
);
pCreateTable
->
uid
=
htobe64
(
pTable
->
uid
);
pCreateTable
->
superTableUid
=
htobe64
(
0
);
pCreateTable
->
createdTime
=
htobe64
(
pTable
->
createdTime
);
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
pCreateTable
->
vpeerDesc
[
i
].
ip
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
ip
);
pCreateTable
->
vpeerDesc
[
i
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
i
].
vnode
);
}
SSchema
*
pSchema
=
(
SSchema
*
)
pCreateTable
->
data
;
memcpy
(
pCreate
->
tableId
,
pTable
->
tableId
,
TSDB_TABLE_ID_LEN
+
1
);
pCreate
->
contLen
=
htonl
(
contLen
);
pCreate
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pCreate
->
tableType
=
pTable
->
type
;
pCreate
->
numOfColumns
=
htons
(
pTable
->
numOfColumns
);
pCreate
->
numOfTags
=
htons
(
0
);
pCreate
->
sid
=
htonl
(
pTable
->
sid
);
pCreate
->
sversion
=
htonl
(
pTable
->
sversion
);
pCreate
->
tagDataLen
=
htonl
(
0
);
pCreate
->
sqlDataLen
=
htonl
(
pTable
->
sqlLen
);
pCreate
->
uid
=
htobe64
(
pTable
->
uid
);
pCreate
->
superTableUid
=
htobe64
(
0
);
pCreate
->
createdTime
=
htobe64
(
pTable
->
createdTime
);
SSchema
*
pSchema
=
(
SSchema
*
)
pCreate
->
data
;
memcpy
(
pSchema
,
pTable
->
schema
,
totalCols
*
sizeof
(
SSchema
));
for
(
int32_t
col
=
0
;
col
<
totalCols
;
++
col
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
...
...
@@ -323,9 +318,9 @@ static void *mgmtBuildCreateNormalTableMsg(SNormalTableObj *pTable, SVgObj *pVgr
pSchema
++
;
}
memcpy
(
pCreate
Table
+
sizeof
(
SMDCreateTableMsg
)
+
totalCols
*
sizeof
(
SSchema
),
pTable
->
sql
,
pTable
->
sqlLen
);
memcpy
(
pCreate
+
sizeof
(
SMDCreateTableMsg
)
+
totalCols
*
sizeof
(
SSchema
),
pTable
->
sql
,
pTable
->
sqlLen
);
return
pCreate
Table
;
return
pCreate
;
}
int32_t
mgmtCreateNormalTable
(
SCMCreateTableMsg
*
pCreate
,
int32_t
contLen
,
SVgObj
*
pVgroup
,
int32_t
sid
,
...
...
src/mnode/src/mgmtSuperTable.c
浏览文件 @
cc4d5078
...
...
@@ -213,7 +213,7 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCMCreateTableMsg *pCreate) {
}
strcpy
(
pStable
->
tableId
,
pCreate
->
tableId
);
pStable
->
type
=
TSDB_
TABLE_TYPE_
SUPER_TABLE
;
pStable
->
type
=
TSDB_SUPER_TABLE
;
pStable
->
createdTime
=
taosGetTimestampMs
();
pStable
->
vgId
=
0
;
pStable
->
sid
=
0
;
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
cc4d5078
...
...
@@ -119,11 +119,11 @@ STableInfo* mgmtGetTableByPos(uint32_t dnodeIp, int32_t vnode, int32_t sid) {
}
int32_t
mgmtGetTableMeta
(
SDbObj
*
pDb
,
STableInfo
*
pTable
,
STableMeta
*
pMeta
,
bool
usePublicIp
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
CHILD_TABLE
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
mgmtGetChildTableMeta
(
pDb
,
(
SChildTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
NORMAL_TABLE
)
{
}
else
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
mgmtGetNormalTableMeta
(
pDb
,
(
SNormalTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
}
else
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
mgmtGetSuperTableMeta
(
pDb
,
(
SSuperTableObj
*
)
pTable
,
pMeta
,
usePublicIp
);
}
else
{
mTrace
(
"%s, uid:%"
PRIu64
" table meta retrieve failed, invalid type"
,
pTable
->
tableId
,
pTable
->
uid
);
...
...
@@ -176,7 +176,7 @@ static void mgmtCreateTable(SVgObj *pVgroup, SQueuedMsg *pMsg) {
SRpcIpSet
ipSet
=
mgmtGetIpSetFromVgroup
(
pVgroup
);
SRpcMsg
rpcMsg
=
{
.
handle
=
pMsg
,
.
pCont
=
pCreate
,
.
pCont
=
p
MD
Create
,
.
contLen
=
htonl
(
pMDCreate
->
contLen
),
.
code
=
0
,
.
msgType
=
TSDB_MSG_TYPE_MD_CREATE_TABLE
...
...
@@ -204,16 +204,16 @@ int32_t mgmtDropTable(SDbObj *pDb, char *tableId, int32_t ignore) {
}
switch
(
pTable
->
type
)
{
case
TSDB_
TABLE_TYPE_
SUPER_TABLE
:
case
TSDB_SUPER_TABLE
:
mTrace
(
"table:%s, start to drop super table"
,
tableId
);
return
mgmtDropSuperTable
(
pDb
,
(
SSuperTableObj
*
)
pTable
);
case
TSDB_
TABLE_TYPE_
CHILD_TABLE
:
case
TSDB_CHILD_TABLE
:
mTrace
(
"table:%s, start to drop child table"
,
tableId
);
return
mgmtDropChildTable
(
pDb
,
(
SChildTableObj
*
)
pTable
);
case
TSDB_
TABLE_TYPE_
NORMAL_TABLE
:
case
TSDB_NORMAL_TABLE
:
mTrace
(
"table:%s, start to drop normal table"
,
tableId
);
return
mgmtDropNormalTable
(
pDb
,
(
SNormalTableObj
*
)
pTable
);
case
TSDB_
TABLE_TYPE_
STREAM_TABLE
:
case
TSDB_STREAM_TABLE
:
mTrace
(
"table:%s, start to drop stream table"
,
tableId
);
return
mgmtDropNormalTable
(
pDb
,
(
SNormalTableObj
*
)
pTable
);
default:
...
...
@@ -233,31 +233,31 @@ int32_t mgmtAlterTable(SDbObj *pDb, SCMAlterTableMsg *pAlter) {
}
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
mgmtAddSuperTableTag
((
SSuperTableObj
*
)
pTable
,
pAlter
->
schema
,
1
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
mgmtDropSuperTableTag
((
SSuperTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
mgmtModifySuperTableTagNameByName
((
SSuperTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
schema
[
1
].
name
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
CHILD_TABLE
)
{
if
(
pTable
->
type
==
TSDB_CHILD_TABLE
)
{
return
mgmtModifyChildTableTagValueByName
((
SChildTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
,
pAlter
->
tagVal
);
}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
NORMAL_TABLE
)
{
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
return
mgmtAddNormalTableColumn
((
SNormalTableObj
*
)
pTable
,
pAlter
->
schema
,
1
);
}
else
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
}
else
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
mgmtAddSuperTableColumn
((
SSuperTableObj
*
)
pTable
,
pAlter
->
schema
,
1
);
}
else
{}
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_COLUMN
)
{
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
NORMAL_TABLE
)
{
if
(
pTable
->
type
==
TSDB_NORMAL_TABLE
)
{
return
mgmtDropNormalTableColumnByName
((
SNormalTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
);
}
else
if
(
pTable
->
type
==
TSDB_
TABLE_TYPE_
SUPER_TABLE
)
{
}
else
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
return
mgmtDropSuperTableColumnByName
((
SSuperTableObj
*
)
pTable
,
pAlter
->
schema
[
0
].
name
);
}
else
{}
}
else
{}
...
...
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
cc4d5078
...
...
@@ -33,13 +33,6 @@ extern "C" {
#define TSDB_INVALID_SUPER_TABLE_ID -1
// --------- TSDB REPOSITORY CONFIGURATION DEFINITION
enum
{
TSDB_PRECISION_MILLI
,
TSDB_PRECISION_MICRO
,
TSDB_PRECISION_NANO
};
typedef
enum
{
TSDB_SUPER_TABLE
,
// super table
TSDB_NTABLE
,
// table not created from super table
TSDB_STABLE
// table created from super table
}
TSDB_TABLE_TYPE
;
typedef
struct
{
int8_t
precision
;
int32_t
vgId
;
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
cc4d5078
...
...
@@ -43,7 +43,7 @@ typedef struct STable {
STSchema
*
tagSchema
;
SDataRow
tagVal
;
union
{
void
*
pData
;
// For TSDB_N
TABLE and TSDB_S
TABLE, it is the skiplist for cache data
void
*
pData
;
// For TSDB_N
ORMAL_TABLE and TSDB_CHILD_
TABLE, it is the skiplist for cache data
void
*
pIndex
;
// For TSDB_SUPER_TABLE, it is the skiplist index
}
content
;
void
*
eventHandler
;
// TODO
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
cc4d5078
...
...
@@ -339,7 +339,7 @@ int32_t tsdbInsertData(tsdb_repo_t *repo, SSubmitMsg *pMsg) {
*/
int
tsdbInitTableCfg
(
STableCfg
*
config
,
TSDB_TABLE_TYPE
type
,
int64_t
uid
,
int32_t
tid
)
{
if
(
config
==
NULL
)
return
-
1
;
if
(
type
!=
TSDB_N
TABLE
&&
type
!=
TSDB_S
TABLE
)
return
-
1
;
if
(
type
!=
TSDB_N
ORMAL_TABLE
&&
type
!=
TSDB_CHILD_
TABLE
)
return
-
1
;
memset
((
void
*
)
config
,
0
,
sizeof
(
STableCfg
));
...
...
@@ -354,7 +354,7 @@ int tsdbInitTableCfg(STableCfg *config, TSDB_TABLE_TYPE type, int64_t uid, int32
* Set the super table UID of the created table
*/
int
tsdbTableSetSuperUid
(
STableCfg
*
config
,
int64_t
uid
)
{
if
(
config
->
type
!=
TSDB_
S
TABLE
)
return
-
1
;
if
(
config
->
type
!=
TSDB_
CHILD_
TABLE
)
return
-
1
;
if
(
uid
==
TSDB_INVALID_SUPER_TABLE_ID
)
return
-
1
;
config
->
superUid
=
uid
;
...
...
@@ -387,7 +387,7 @@ int tsdbTableSetSchema(STableCfg *config, STSchema *pSchema, bool dup) {
* @return 0 for success and -1 for failure
*/
int
tsdbTableSetTagSchema
(
STableCfg
*
config
,
STSchema
*
pSchema
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_
S
TABLE
)
return
-
1
;
if
(
config
->
type
!=
TSDB_
CHILD_
TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagSchema
=
tdDupSchema
(
pSchema
);
...
...
@@ -398,7 +398,7 @@ int tsdbTableSetTagSchema(STableCfg *config, STSchema *pSchema, bool dup) {
}
int
tsdbTableSetTagValue
(
STableCfg
*
config
,
SDataRow
row
,
bool
dup
)
{
if
(
config
->
type
!=
TSDB_
S
TABLE
)
return
-
1
;
if
(
config
->
type
!=
TSDB_
CHILD_
TABLE
)
return
-
1
;
if
(
dup
)
{
config
->
tagValues
=
tdDataRowDup
(
row
);
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
cc4d5078
...
...
@@ -138,7 +138,7 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
STable
*
super
=
NULL
;
int
newSuper
=
0
;
if
(
pCfg
->
type
==
TSDB_
STABLE
)
{
if
(
pCfg
->
type
==
TSDB_
CHILD_TABLE
)
{
super
=
tsdbGetTableByUid
(
pMeta
,
pCfg
->
superUid
);
if
(
super
==
NULL
)
{
// super table not exists, try to create it
newSuper
=
1
;
...
...
@@ -175,12 +175,12 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
}
table
->
tableId
=
pCfg
->
tableId
;
if
(
IS_CREATE_STABLE
(
pCfg
))
{
// TSDB_
S
TABLE
table
->
type
=
TSDB_
S
TABLE
;
if
(
IS_CREATE_STABLE
(
pCfg
))
{
// TSDB_
CHILD_
TABLE
table
->
type
=
TSDB_
CHILD_
TABLE
;
table
->
superUid
=
pCfg
->
superUid
;
table
->
tagVal
=
tdDataRowDup
(
pCfg
->
tagValues
);
}
else
{
// TSDB_NTABLE
table
->
type
=
TSDB_NTABLE
;
}
else
{
// TSDB_N
ORMAL_
TABLE
table
->
type
=
TSDB_N
ORMAL_
TABLE
;
table
->
superUid
=
-
1
;
table
->
schema
=
tdDupSchema
(
pCfg
->
schema
);
}
...
...
@@ -221,7 +221,7 @@ int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
NULL
;
pMeta
->
nTables
--
;
assert
(
pMeta
->
nTables
>=
0
);
if
(
pTable
->
type
==
TSDB_
S
TABLE
)
{
if
(
pTable
->
type
==
TSDB_
CHILD_
TABLE
)
{
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
...
...
@@ -238,7 +238,7 @@ int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable) {
static
int
tsdbFreeTable
(
STable
*
pTable
)
{
// TODO: finish this function
if
(
pTable
->
type
==
TSDB_
S
TABLE
)
{
if
(
pTable
->
type
==
TSDB_
CHILD_
TABLE
)
{
tdFreeDataRow
(
pTable
->
tagVal
);
}
else
{
tdFreeSchema
(
pTable
->
schema
);
...
...
@@ -282,7 +282,7 @@ static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable) {
}
else
{
// add non-super table to the array
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
pTable
;
if
(
pTable
->
type
==
TSDB_
S
TABLE
)
{
if
(
pTable
->
type
==
TSDB_
CHILD_
TABLE
)
{
// add STABLE to the index
tsdbAddTableIntoIndex
(
pMeta
,
pTable
);
}
...
...
@@ -306,13 +306,13 @@ static int tsdbAddTableIntoMap(STsdbMeta *pMeta, STable *pTable) {
return
0
;
}
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
assert
(
pTable
->
type
==
TSDB_
S
TABLE
);
assert
(
pTable
->
type
==
TSDB_
CHILD_
TABLE
);
// TODO
return
0
;
}
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
assert
(
pTable
->
type
==
TSDB_
S
TABLE
);
assert
(
pTable
->
type
==
TSDB_
CHILD_
TABLE
);
// TODO
return
0
;
}
...
...
src/vnode/tsdb/tests/tsdbTests.cpp
浏览文件 @
cc4d5078
...
...
@@ -15,7 +15,7 @@ TEST(TsdbTest, createRepo) {
// 2. Create a normal table
STableCfg
tCfg
;
ASSERT_EQ
(
tsdbInitTableCfg
(
&
tCfg
,
TSDB_SUPER_TABLE
,
987607499877672L
,
0
),
-
1
);
ASSERT_EQ
(
tsdbInitTableCfg
(
&
tCfg
,
TSDB_NTABLE
,
987607499877672L
,
0
),
0
);
ASSERT_EQ
(
tsdbInitTableCfg
(
&
tCfg
,
TSDB_N
ORMAL_
TABLE
,
987607499877672L
,
0
),
0
);
int
nCols
=
5
;
STSchema
*
schema
=
tdNewSchema
(
nCols
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录