Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ca45e6c9
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看板
提交
ca45e6c9
编写于
4月 20, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact meta 4
上级
bd36dc99
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
66 addition
and
69 deletion
+66
-69
include/common/tmsg.h
include/common/tmsg.h
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-7
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+38
-50
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+3
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+5
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+13
-11
未找到文件。
include/common/tmsg.h
浏览文件 @
ca45e6c9
...
@@ -1479,7 +1479,7 @@ typedef struct SVCreateStbReq {
...
@@ -1479,7 +1479,7 @@ typedef struct SVCreateStbReq {
SSchema
*
pSchema
;
SSchema
*
pSchema
;
int16_t
nTags
;
int16_t
nTags
;
SSchema
*
pSchemaTg
;
SSchema
*
pSchemaTg
;
SRSmaParam
*
pRSmaParam
;
SRSmaParam
pRSmaParam
;
}
SVCreateStbReq
;
}
SVCreateStbReq
;
int
tEncodeSVCreateStbReq
(
SCoder
*
pCoder
,
const
SVCreateStbReq
*
pReq
);
int
tEncodeSVCreateStbReq
(
SCoder
*
pCoder
,
const
SVCreateStbReq
*
pReq
);
...
...
source/common/src/tmsg.c
浏览文件 @
ca45e6c9
...
@@ -3076,7 +3076,6 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
...
@@ -3076,7 +3076,6 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
return
0
;
return
0
;
}
}
int32_t
tSerializeSAlterVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReq
*
pReq
)
{
int32_t
tSerializeSAlterVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -3129,7 +3128,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
...
@@ -3129,7 +3128,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
return
0
;
return
0
;
}
}
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -3723,16 +3721,17 @@ int tDecodeSVCreateStbReq(SCoder *pCoder, SVCreateStbReq *pReq) {
...
@@ -3723,16 +3721,17 @@ int tDecodeSVCreateStbReq(SCoder *pCoder, SVCreateStbReq *pReq) {
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
rollup
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
rollup
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nCols
)
<
0
)
return
-
1
;
// TCODER_MALLOC(pReq->pSchema, SSchema, sizeof(SSchema) * pReq->nCols, pCoder);
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nCols
)
<
0
)
return
-
1
;
pReq
->
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pReq
->
nCols
);
pReq
->
pSchema
=
(
SSchema
*
)
TCODER_MALLOC
(
pCoder
,
sizeof
(
SSchema
)
*
pReq
->
nCols
);
if
(
pReq
->
pSchema
==
NULL
)
return
-
1
;
for
(
int
iCol
=
0
;
iCol
<
pReq
->
nCols
;
iCol
++
)
{
for
(
int
iCol
=
0
;
iCol
<
pReq
->
nCols
;
iCol
++
)
{
if
(
tDecodeSSchema
(
pCoder
,
pReq
->
pSchema
+
iCol
)
<
0
)
return
-
1
;
if
(
tDecodeSSchema
(
pCoder
,
pReq
->
pSchema
+
iCol
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nTags
)
<
0
)
return
-
1
;
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nTags
)
<
0
)
return
-
1
;
// TCODER_MALLOC(pReq->pSchemaTg, SSchema, sizeof(SSchema) * pReq->nTags, pCoder);
pReq
->
pSchemaTg
=
(
SSchema
*
)
TCODER_MALLOC
(
pCoder
,
sizeof
(
SSchema
)
*
pReq
->
nTags
);
if
(
pReq
->
pSchemaTg
==
NULL
)
return
-
1
;
pReq
->
pSchemaTg
=
(
SSchema
*
)
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pReq
->
nTags
);
pReq
->
pSchemaTg
=
(
SSchema
*
)
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pReq
->
nTags
);
for
(
int
iTag
=
0
;
iTag
<
pReq
->
nTags
;
iTag
++
)
{
for
(
int
iTag
=
0
;
iTag
<
pReq
->
nTags
;
iTag
++
)
{
if
(
tDecodeSSchema
(
pCoder
,
pReq
->
pSchemaTg
+
iTag
)
<
0
)
return
-
1
;
if
(
tDecodeSSchema
(
pCoder
,
pReq
->
pSchemaTg
+
iTag
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
ca45e6c9
...
@@ -394,66 +394,55 @@ static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSch
...
@@ -394,66 +394,55 @@ static FORCE_INLINE int schemaExColIdCompare(const void *colId, const void *pSch
}
}
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
#if 0
SCoder
coder
;
int32_t
contLen
;
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreate
T
bReq req = {0};
SVCreate
St
bReq
req
=
{
0
};
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req.ttl = 0;
req
.
suid
=
pStb
->
uid
;
req.keep = 0;
req
.
rollup
=
pStb
->
aggregationMethod
>
-
1
?
1
:
0
;
req
.
rollup
=
pStb
->
aggregationMethod
>
-
1
?
1
:
0
;
req.type = TD_SUPER_TABLE;
req
.
ttl
=
0
;
req.stbCfg.suid = pStb->uid;
req
.
nCols
=
pStb
->
numOfColumns
;
req.stbCfg.nCols = pStb->numOfColumns;
req
.
pSchema
=
pStb
->
pColumns
;
req.stbCfg.nTagCols = pStb->numOfTags;
req
.
nTags
=
pStb
->
numOfTags
;
req.stbCfg.pTagSchema = pStb->pTags;
req
.
pSchemaTg
=
pStb
->
pTags
;
req.stbCfg.pSchema = (SSchema *)taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema));
if (req.stbCfg.pSchema == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
memcpy(req.stbCfg.pSchema, pStb->pColumns, sizeof(SSchema) * pStb->numOfColumns);
// TODO: remove here
for (int i
= 0; i < pStb->numOfColumns; i
++) {
for
(
int
i
Col
=
0
;
iCol
<
req
.
nCols
;
iCol
++
)
{
req.
stbCfg.pSchema[i
].flags = SCHEMA_SMA_ON;
req
.
pSchema
[
iCol
].
flags
=
SCHEMA_SMA_ON
;
}
}
SRSmaParam *pRSmaParam = NULL;
if
(
req
.
rollup
)
{
if
(
req
.
rollup
)
{
pRSmaParam = (SRSmaParam *)taosMemoryCalloc(1, sizeof(SRSmaParam));
req
.
pRSmaParam
.
xFilesFactor
=
pStb
->
xFilesFactor
;
if (pRSmaParam == NULL) {
req
.
pRSmaParam
.
delay
=
pStb
->
delay
;
taosMemoryFreeClear(req.stbCfg.pSchema);
req
.
pRSmaParam
.
nFuncIds
=
1
;
// only 1 aggregation method supported currently
req
.
pRSmaParam
.
pFuncIds
=
(
func_id_t
*
)
taosMemoryCalloc
(
req
.
pRSmaParam
.
nFuncIds
,
sizeof
(
func_id_t
));
if
(
req
.
pRSmaParam
.
pFuncIds
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
for
(
int32_t
f
=
0
;
f
<
req
.
pRSmaParam
.
nFuncIds
;
++
f
)
{
pRSmaParam->xFilesFactor = pStb->xFilesFactor;
req
.
pRSmaParam
.
pFuncIds
[
f
]
=
pStb
->
aggregationMethod
;
pRSmaParam->delay = pStb->delay;
pRSmaParam->nFuncIds = 1; // only 1 aggregation method supported currently
pRSmaParam->pFuncIds = (func_id_t *)taosMemoryCalloc(pRSmaParam->nFuncIds, sizeof(func_id_t));
if (pRSmaParam->pFuncIds == NULL) {
taosMemoryFreeClear(req.stbCfg.pRSmaParam);
taosMemoryFreeClear(req.stbCfg.pSchema);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
}
for (int32_t f = 0; f < pRSmaParam->nFuncIds; ++f) {
*(pRSmaParam->pFuncIds + f) = pStb->aggregationMethod;
}
}
req.stbCfg.pRSmaParam = pRSmaParam;
// get length
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
if
(
tEncodeSVCreateStbReq
(
&
coder
,
&
req
)
<
0
)
{
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
return
NULL
;
}
}
tCoderClear
(
&
coder
);
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead)
;
contLen
=
sizeof
(
SMsgHead
)
+
coder
.
pos
;
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
if (pRSmaParam) {
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
taosMemoryFreeClear(pRSmaParam->pFuncIds);
taosMemoryFreeClear(pRSmaParam);
}
// taosMemoryFreeClear(req.stbCfg.pSchema);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
...
@@ -462,17 +451,16 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -462,17 +451,16 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
void
*
pBuf
=
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq(&pBuf, &req);
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
pBuf
,
contLen
-
sizeof
(
SMsgHead
),
TD_ENCODER
);
if
(
tEncodeSVCreateStbReq
(
&
coder
,
&
req
)
<
0
)
{
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
return
NULL
;
}
tCoderClear
(
&
coder
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
if (pRSmaParam) {
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
taosMemoryFreeClear(pRSmaParam->pFuncIds);
taosMemoryFreeClear(pRSmaParam);
}
// taosMemoryFreeClear(req.stbCfg.pSchema);
return
pHead
;
return
pHead
;
#endif
return
NULL
;
}
}
static
void
*
mndBuildVDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildVDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
ca45e6c9
...
@@ -45,6 +45,9 @@ void metaCloseIdx(SMeta* pMeta);
...
@@ -45,6 +45,9 @@ void metaCloseIdx(SMeta* pMeta);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// metaTable ==================
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
);
// metaCommit ==================
// metaCommit ==================
int
metaBegin
(
SMeta
*
pMeta
);
int
metaBegin
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
ca45e6c9
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
)
{
// TODO
return
0
;
}
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
#ifdef META_REFACT
#ifdef META_REFACT
#else
#else
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
ca45e6c9
...
@@ -196,20 +196,22 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -196,20 +196,22 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
}
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int
len
)
{
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int
len
)
{
SVCreateTbReq
vCreateTbReq
=
{
0
};
SVCreateStbReq
req
=
{
0
};
tDeserializeSVCreateTbReq
(
pReq
,
&
vCreateTbReq
);
SCoder
coder
;
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
// TODO
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
pReq
,
len
,
TD_DECODER
);
if
(
tDecodeSVCreateStbReq
(
&
coder
,
&
req
)
<
0
)
{
tCoderClear
(
&
coder
);
return
-
1
;
return
-
1
;
}
}
// taosMemoryFree(vCreateTbReq.stbCfg.pSchema);
if
(
metaCreateSTable
(
pVnode
->
pMeta
,
pReq
,
NULL
)
<
0
)
{
// taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema);
tCoderClear
(
&
coder
);
// if (vCreateTbReq.stbCfg.pRSmaParam) {
return
-
1
;
// taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds);
}
// taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam);
// }
tCoderClear
(
&
coder
);
// taosMemoryFree(vCreateTbReq.name);
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录