Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8ca5e026
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8ca5e026
编写于
11月 29, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adjust more code
上级
3e2f7980
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
93 addition
and
86 deletion
+93
-86
include/common/tmsg.h
include/common/tmsg.h
+13
-12
source/common/src/tmsg.c
source/common/src/tmsg.c
+44
-36
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+32
-36
source/util/src/tarray.c
source/util/src/tarray.c
+4
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
8ca5e026
...
...
@@ -3202,29 +3202,30 @@ int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq);
int32_t
tSerializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
int32_t
tDeserializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
typedef
struct
{
bool
isColFmt
;
int64_t
suid
;
int64_t
uid
;
int32_t
sver
;
int32_t
flags
;
SVCreateTbReq
*
pCreateTbReq
;
int64_t
suid
;
int64_t
uid
;
int32_t
sver
;
union
{
SArray
*
aRowP
;
SArray
*
aCol
;
};
}
SSubmitTbData
;
#define SUBMIT_REQ_AUTO_CREATE_TABLE 0x1
#define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2
typedef
struct
{
int32_t
flag
;
SArray
*
aCreateTbReq
;
SArray
*
aSubmitTbData
;
SArray
*
aSubmitTbData
;
// SArray<SSubmitTbData>
}
SSubmitReq2
;
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
);
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
**
ppReq
);
void
tDestroySSubmitTbData
(
SSubmitTbData
*
pTbData
);
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
);
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
*
pReq
);
void
tDestroySSubmitTbData
(
SSubmitTbData
*
pTbData
);
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
);
typedef
struct
{
int32_t
code
;
...
...
source/common/src/tmsg.c
浏览文件 @
8ca5e026
...
...
@@ -6651,20 +6651,28 @@ int32_t tDecodeSBatchDeleteReq(SDecoder *pDecoder, SBatchDeleteReq *pReq) {
return
0
;
}
static
int32_t
tEncodeSSubmitTbData
(
SEncoder
*
pCoder
,
const
SSubmitTbData
*
pSubmitTbData
,
int8_t
colFmt
)
{
static
int32_t
tEncodeSSubmitTbData
(
SEncoder
*
pCoder
,
const
SSubmitTbData
*
pSubmitTbData
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pSubmitTbData
->
flags
)
<
0
)
return
-
1
;
// auto create table
if
(
pSubmitTbData
->
flags
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
ASSERT
(
pSubmitTbData
->
pCreateTbReq
);
if
(
tEncodeSVCreateTbReq
(
pCoder
,
pSubmitTbData
->
pCreateTbReq
)
<
0
)
return
-
1
;
}
// submit data
if
(
tEncodeI64
(
pCoder
,
pSubmitTbData
->
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pCoder
,
pSubmitTbData
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pSubmitTbData
->
sver
)
<
0
)
return
-
1
;
if
(
colFmt
)
{
// todo
ASSERT
(
0
);
if
(
pSubmitTbData
->
flags
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
{
ASSERT
(
0
);
// TODO
}
else
{
if
(
tEncode
I
64v
(
pCoder
,
taosArrayGetSize
(
pSubmitTbData
->
aRowP
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pSubmitTbData
->
aRowP
);
i
++
)
{
SRow
*
pRow
=
taosArrayGetP
(
pSubmitTbData
->
aRowP
,
i
);
if
(
tEncode
U
64v
(
pCoder
,
taosArrayGetSize
(
pSubmitTbData
->
aRowP
))
<
0
)
return
-
1
;
for
(
int32_t
i
Row
=
0
;
iRow
<
taosArrayGetSize
(
pSubmitTbData
->
aRowP
);
++
iRow
)
{
SRow
*
pRow
=
taosArrayGetP
(
pSubmitTbData
->
aRowP
,
i
Row
);
if
(
pCoder
->
data
)
memcpy
(
pCoder
->
data
+
pCoder
->
pos
,
pRow
,
pRow
->
len
);
pCoder
->
pos
+=
pRow
->
len
;
}
...
...
@@ -6682,6 +6690,22 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa
goto
_exit
;
}
if
(
tDecodeI32v
(
pCoder
,
&
pSubmitTbData
->
flags
)
<
0
)
return
-
1
;
if
(
pSubmitTbData
->
flags
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
pSubmitTbData
->
pCreateTbReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVCreateTbReq
));
if
(
pSubmitTbData
->
pCreateTbReq
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
if
(
tDecodeSVCreateTbReq
(
pCoder
,
pSubmitTbData
->
pCreateTbReq
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
}
// submit data
if
(
tDecodeI64
(
pCoder
,
&
pSubmitTbData
->
suid
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
...
...
@@ -6695,24 +6719,24 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa
goto
_exit
;
}
if
(
colFmt
)
{
// todo
ASSERT
(
0
);
if
(
pSubmitTbData
->
flags
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
{
ASSERT
(
0
);
// TODO
}
else
{
int64_t
nRows
=
0
;
if
(
tDecode
I64v
(
pCoder
,
&
nRows
)
<
0
)
{
uint64_t
nRow
;
if
(
tDecode
U64v
(
pCoder
,
&
nRow
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
pSubmitTbData
->
aRowP
=
taosArrayInit
(
nRow
s
,
sizeof
(
SRow
*
));
pSubmitTbData
->
aRowP
=
taosArrayInit
(
nRow
,
sizeof
(
SRow
*
));
if
(
pSubmitTbData
->
aRowP
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
for
(
int32_t
i
=
0
;
i
<
nRows
;
i
++
)
{
for
(
int32_t
i
Row
=
0
;
iRow
<
nRow
;
++
iRow
)
{
SRow
**
ppRow
=
taosArrayReserve
(
pSubmitTbData
->
aRowP
,
1
);
*
ppRow
=
(
SRow
*
)(
pCoder
->
data
+
pCoder
->
pos
);
pCoder
->
pos
+=
(
*
ppRow
)
->
len
;
}
...
...
@@ -6722,7 +6746,7 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa
_exit:
if
(
code
)
{
//
todo: do
clear
//
TODO:
clear
}
return
0
;
}
...
...
@@ -6730,35 +6754,19 @@ _exit:
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pReq
->
flag
)
<
0
)
return
-
1
;
if
(
pReq
->
flag
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
if
(
tEncodeI64v
(
pCoder
,
taosArrayGetSize
(
pReq
->
aCreateTbReq
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pReq
->
aCreateTbReq
);
++
i
)
{
SVCreateTbReq
*
pCreateTbReq
=
(
SVCreateTbReq
*
)
taosArrayGet
(
pReq
->
aCreateTbReq
,
i
);
if
(
tEncodeSVCreateTbReq
(
pCoder
,
pCreateTbReq
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI64v
(
pCoder
,
taosArrayGetSize
(
pReq
->
aSubmitTbData
))
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
(
SSubmitTbData
*
)
taosArrayGet
(
pReq
->
aSubmitTbData
,
i
);
if
(
tEncodeSSubmitTbData
(
pCoder
,
pSubmitTbData
,
pReq
->
flag
&
SUBMIT_REQ_COLUMN_DATA_FORMAT
)
<
0
)
return
-
1
;
if
(
tEncodeU64v
(
pCoder
,
taosArrayGetSize
(
pReq
->
aSubmitTbData
))
<
0
)
return
-
1
;
for
(
uint64_t
i
=
0
;
i
<
taosArrayGetSize
(
pReq
->
aSubmitTbData
);
i
++
)
{
if
(
tEncodeSSubmitTbData
(
pCoder
,
taosArrayGet
(
pReq
->
aSubmitTbData
,
i
))
<
0
)
return
-
1
;
}
tEndEncode
(
pCoder
);
return
0
;
}
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
*
*
p
pReq
)
{
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
*
pReq
)
{
int32_t
code
=
0
;
// alloc
SSubmitReq2
*
pReq
=
(
SSubmitReq2
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSubmitReq2
));
if
(
pReq
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
memset
(
pReq
,
0
,
sizeof
(
*
pReq
));
// decode
if
(
tStartDecode
(
pCoder
)
<
0
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
8ca5e026
...
...
@@ -822,29 +822,12 @@ static int32_t vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock,
return
TSDB_CODE_SUCCESS
;
}
// static int32_t vnodeDebugPrintSubmitMsg(SVnode *pVnode, SSubmitReq *pMsg, const char *tags) {
// ASSERT(pMsg != NULL);
// SSubmitMsgIter msgIter = {0};
// SMeta *pMeta = pVnode->pMeta;
// SSubmitBlk *pBlock = NULL;
// if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) return -1;
// while (true) {
// if (tGetSubmitMsgNext(&msgIter, &pBlock) < 0) return -1;
// if (pBlock == NULL) break;
// vnodeDebugPrintSingleSubmitMsg(pMeta, pBlock, &msgIter, tags);
// }
// return 0;
// }
static
int32_t
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
#if 1
int32_t
code
=
0
;
SSubmitRsp2
submitRsp
=
{
0
};
SSubmitReq2
*
pSubmitReq
=
NULL
;
SSubmitRsp2
*
pSubmitRsp
=
NULL
;
SArray
*
newTbUids
=
NULL
;
// decode
...
...
@@ -856,25 +839,39 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
}
tDecoderClear
(
&
dc
);
// init
code
=
tCreateSSubmitRsp2
(
&
pSubmitRsp
);
if
(
code
)
goto
_exit
;
// auto create table
if
(
pSubmitReq
->
flag
&
SUBMIT_REQ_AUTO_CREATE_TABLE
)
{
for
(
int32_t
iCreateTbReq
=
0
;
iCreateTbReq
<
taosArrayGetSize
(
pSubmitReq
->
aCreateTbReq
);
iCreateTbReq
++
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
pSubmitReq
->
aCreateTbReq
,
iCreateTbReq
);
for
(
int32_t
iCreateTbReq
=
0
;
iCreateTbReq
<
taosArrayGetSize
(
pSubmitReq
->
aCreateTbReq
);
iCreateTbReq
++
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
pSubmitReq
->
aCreateTbReq
,
iCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
version
,
pCreateTbReq
,
NULL
/* todo */
)
<
0
)
{
if
(
terrno
!=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
// todo
}
}
else
{
SVCreateTbRsp
*
pCreateTbRsp
=
taosArrayReserve
(
pSubmitRsp
->
aCreateTbRsp
,
1
);
if
(
pCreateTbRsp
==
NULL
)
{
code
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_exit
;
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
version
,
pCreateTbReq
,
&
pCreateTbRsp
->
pMeta
)
<
0
)
{
if
(
terrno
!=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
// todo
}
}
else
{
// todo
}
}
// check
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pSubmitReq
->
aSubmitTbData
,
i
);
// TODO
}
// // check
// for (int32_t i = 0; i < taosArrayGetSize(pSubmitReq->aSubmitTbData); ++i) {
// SSubmitTbData *pSubmitTbData = taosArrayGet(pSubmitReq->aSubmitTbData, i);
// SMetaInfo info = {0};
// code = metaGetInfo(pVnode->pMeta, pSubmitTbData->uid, &info, NULL);
// if (code) {
// // TODO
// }
// }
// insert table data
for
(
int32_t
iSubmitTbData
=
0
;
iSubmitTbData
<
taosArrayGetSize
(
pSubmitReq
->
aSubmitTbData
);
iSubmitTbData
++
)
{
...
...
@@ -882,7 +879,10 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
SSubmitBlkRsp
submitBlkRsp
=
{
0
};
tsdbInsertTableData
(
pVnode
->
pTsdb
,
version
,
pSubmitTbData
,
&
submitBlkRsp
);
code
=
tsdbInsertTableData
(
pVnode
->
pTsdb
,
version
,
pSubmitTbData
,
&
submitBlkRsp
);
if
(
code
)
goto
_exit
;
pSubmitRsp
->
affectedRows
+=
taosArrayGetSize
(
pSubmitTbData
->
aRowP
);
}
_exit:
...
...
@@ -910,10 +910,6 @@ _exit:
pSubmitReq
->
version
=
version
;
statis
.
nBatchInsert
=
1
;
#ifdef TD_DEBUG_PRINT_ROW
vnodeDebugPrintSubmitMsg
(
pVnode
,
pReq
,
__func__
);
#endif
if
(
tsdbScanAndConvertSubmitMsg
(
pVnode
->
pTsdb
,
pSubmitReq
)
<
0
)
{
pRsp
->
code
=
terrno
;
goto
_exit
;
...
...
source/util/src/tarray.c
浏览文件 @
8ca5e026
...
...
@@ -191,6 +191,8 @@ void* taosArrayReserve(SArray* pArray, int32_t num) {
void
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
pArray
->
size
);
pArray
->
size
+=
num
;
memset
(
dst
,
0
,
num
*
pArray
->
elemSize
);
return
dst
;
}
...
...
@@ -333,9 +335,9 @@ SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn) {
}
else
{
ASSERT
(
pSrc
->
elemSize
==
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
pSrc
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pSrc
->
size
;
++
i
)
{
void
*
p
=
fn
(
taosArrayGetP
(
pSrc
,
i
));
memcpy
(((
char
*
)
dst
->
pData
)
+
i
*
dst
->
elemSize
,
&
p
,
dst
->
elemSize
);
memcpy
(((
char
*
)
dst
->
pData
)
+
i
*
dst
->
elemSize
,
&
p
,
dst
->
elemSize
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录