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 {
SSchema
*
pSchema
;
int16_t
nTags
;
SSchema
*
pSchemaTg
;
SRSmaParam
*
pRSmaParam
;
SRSmaParam
pRSmaParam
;
}
SVCreateStbReq
;
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
return
0
;
}
int32_t
tSerializeSAlterVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
@@ -3096,7 +3095,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -3129,7 +3128,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
return
0
;
}
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
@@ -3723,16 +3721,17 @@ int tDecodeSVCreateStbReq(SCoder *pCoder, SVCreateStbReq *pReq) {
if
(
tDecodeI64
(
pCoder
,
&
pReq
->
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pCoder
,
&
pReq
->
rollup
)
<
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);
pReq
->
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pReq
->
nCols
);
if
(
tDecodeI16v
(
pCoder
,
&
pReq
->
nCols
)
<
0
)
return
-
1
;
pReq
->
pSchema
=
(
SSchema
*
)
TCODER_MALLOC
(
pCoder
,
sizeof
(
SSchema
)
*
pReq
->
nCols
);
if
(
pReq
->
pSchema
==
NULL
)
return
-
1
;
for
(
int
iCol
=
0
;
iCol
<
pReq
->
nCols
;
iCol
++
)
{
if
(
tDecodeSSchema
(
pCoder
,
pReq
->
pSchema
+
iCol
)
<
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
);
for
(
int
iTag
=
0
;
iTag
<
pReq
->
nTags
;
iTag
++
)
{
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
}
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
#if 0
SName name = {0};
SCoder
coder
;
int32_t
contLen
;
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreate
T
bReq req = {0};
SVCreate
St
bReq
req
=
{
0
};
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req.ttl = 0;
req.keep = 0;
req
.
suid
=
pStb
->
uid
;
req
.
rollup
=
pStb
->
aggregationMethod
>
-
1
?
1
:
0
;
req.type = TD_SUPER_TABLE;
req.stbCfg.suid = pStb->uid;
req.stbCfg.nCols = pStb->numOfColumns;
req.stbCfg.nTagCols = pStb->numOfTags;
req.stbCfg.pTagSchema = pStb->pTags;
req.stbCfg.pSchema = (SSchema *)taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema));
if (req.stbCfg.pSchema == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
req
.
ttl
=
0
;
req
.
nCols
=
pStb
->
numOfColumns
;
req
.
pSchema
=
pStb
->
pColumns
;
req
.
nTags
=
pStb
->
numOfTags
;
req
.
pSchemaTg
=
pStb
->
pTags
;
memcpy(req.stbCfg.pSchema, pStb->pColumns, sizeof(SSchema) * pStb->numOfColumns);
for (int i
= 0; i < pStb->numOfColumns; i
++) {
req.
stbCfg.pSchema[i
].flags = SCHEMA_SMA_ON;
// TODO: remove here
for
(
int
i
Col
=
0
;
iCol
<
req
.
nCols
;
iCol
++
)
{
req
.
pSchema
[
iCol
].
flags
=
SCHEMA_SMA_ON
;
}
SRSmaParam *pRSmaParam = NULL;
if
(
req
.
rollup
)
{
pRSmaParam = (SRSmaParam *)taosMemoryCalloc(1, sizeof(SRSmaParam));
if (pRSmaParam == NULL) {
taosMemoryFreeClear(req.stbCfg.pSchema);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pRSmaParam->xFilesFactor = pStb->xFilesFactor;
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);
req
.
pRSmaParam
.
xFilesFactor
=
pStb
->
xFilesFactor
;
req
.
pRSmaParam
.
delay
=
pStb
->
delay
;
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
;
return
NULL
;
}
for (int32_t f = 0; f <
pRSmaParam->
nFuncIds; ++f) {
*(pRSmaParam->pFuncIds + f)
= pStb->aggregationMethod;
for
(
int32_t
f
=
0
;
f
<
req
.
pRSmaParam
.
nFuncIds
;
++
f
)
{
req
.
pRSmaParam
.
pFuncIds
[
f
]
=
pStb
->
aggregationMethod
;
}
req.stbCfg.pRSmaParam = pRSmaParam;
}
int32_t contLen = tSerializeSVCreateTbReq(NULL, &req) + sizeof(SMsgHead);
// get length
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
if
(
tEncodeSVCreateStbReq
(
&
coder
,
&
req
)
<
0
)
{
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
return
NULL
;
}
tCoderClear
(
&
coder
);
contLen
=
sizeof
(
SMsgHead
)
+
coder
.
pos
;
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
if (pRSmaParam) {
taosMemoryFreeClear(pRSmaParam->pFuncIds);
taosMemoryFreeClear(pRSmaParam);
}
// taosMemoryFreeClear(req.stbCfg.pSchema);
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
...
...
@@ -462,17 +451,16 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
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
;
if (pRSmaParam) {
taosMemoryFreeClear(pRSmaParam->pFuncIds);
taosMemoryFreeClear(pRSmaParam);
}
// taosMemoryFreeClear(req.stbCfg.pSchema);
taosMemoryFree
(
req
.
pRSmaParam
.
pFuncIds
);
return
pHead
;
#endif
return
NULL
;
}
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);
int
metaSaveTableToIdx
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// metaTable ==================
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
);
// metaCommit ==================
int
metaBegin
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
ca45e6c9
...
...
@@ -15,6 +15,11 @@
#include "vnodeInt.h"
int
metaCreateSTable
(
SMeta
*
pMeta
,
SVCreateStbReq
*
pReq
,
SVCreateStbRsp
*
pRsp
)
{
// TODO
return
0
;
}
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
#ifdef META_REFACT
#else
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
ca45e6c9
...
...
@@ -196,20 +196,22 @@ int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int
len
)
{
SVCreateTbReq
vCreateTbReq
=
{
0
};
tDeserializeSVCreateTbReq
(
pReq
,
&
vCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
// TODO
SVCreateStbReq
req
=
{
0
};
SCoder
coder
;
tCoderInit
(
&
coder
,
TD_LITTLE_ENDIAN
,
pReq
,
len
,
TD_DECODER
);
if
(
tDecodeSVCreateStbReq
(
&
coder
,
&
req
)
<
0
)
{
tCoderClear
(
&
coder
);
return
-
1
;
}
// taosMemoryFree(vCreateTbReq.stbCfg.pSchema);
// taosMemoryFree(vCreateTbReq.stbCfg.pTagSchema);
// if (vCreateTbReq.stbCfg.pRSmaParam) {
// taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam->pFuncIds);
// taosMemoryFree(vCreateTbReq.stbCfg.pRSmaParam);
// }
// taosMemoryFree(vCreateTbReq.name);
if
(
metaCreateSTable
(
pVnode
->
pMeta
,
pReq
,
NULL
)
<
0
)
{
tCoderClear
(
&
coder
);
return
-
1
;
}
tCoderClear
(
&
coder
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录