Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6ecd5b29
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
6ecd5b29
编写于
2月 18, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
2月 18, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20019 from taosdata/enh/3.0_planner_optimize
feat: compatible with older versions of wal
上级
a860f6ca
0f4de9da
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
277 addition
and
68 deletion
+277
-68
include/common/tmsg.h
include/common/tmsg.h
+7
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-2
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+5
-5
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+4
-4
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+2
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+18
-18
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+15
-15
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+207
-10
source/libs/executor/src/dataInserter.c
source/libs/executor/src/dataInserter.c
+5
-4
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+8
-8
未找到文件。
include/common/tmsg.h
浏览文件 @
6ecd5b29
...
...
@@ -3307,6 +3307,12 @@ typedef struct {
SArray
*
aSubmitTbData
;
// SArray<SSubmitTbData>
}
SSubmitReq2
;
typedef
struct
{
SMsgHead
header
;
int64_t
version
;
char
data
[];
// SSubmitReq2
}
SSubmitReq2Msg
;
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
);
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
*
pReq
);
void
tDestroySSubmitTbData
(
SSubmitTbData
*
pTbData
,
int32_t
flag
);
...
...
@@ -3323,6 +3329,7 @@ void tDestroySSubmitRsp2(SSubmitRsp2* pRsp, int32_t flag);
#define TSDB_MSG_FLG_ENCODE 0x1
#define TSDB_MSG_FLG_DECODE 0x2
#define TSDB_MSG_FLG_CMPT 0x3
typedef
struct
{
union
{
...
...
source/common/src/tmsg.c
浏览文件 @
6ecd5b29
...
...
@@ -6995,9 +6995,13 @@ void tDestroySSubmitTbData(SSubmitTbData *pTbData, int32_t flag) {
return
;
}
if
(
flag
==
TSDB_MSG_FLG_ENCODE
)
{
if
(
flag
==
TSDB_MSG_FLG_ENCODE
||
flag
==
TSDB_MSG_FLG_CMPT
)
{
if
(
pTbData
->
pCreateTbReq
)
{
if
(
flag
==
TSDB_MSG_FLG_ENCODE
)
{
tdDestroySVCreateTbReq
(
pTbData
->
pCreateTbReq
);
}
else
{
tDestroySVCreateTbReq
(
pTbData
->
pCreateTbReq
,
TSDB_MSG_FLG_DECODE
);
}
taosMemoryFree
(
pTbData
->
pCreateTbReq
);
}
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
6ecd5b29
...
...
@@ -258,7 +258,6 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
SSubmitTbData
tbData
=
{
0
};
if
(
!
(
tbData
.
aRowP
=
taosArrayInit
(
rows
,
sizeof
(
SRow
*
))))
{
goto
_end
;
}
...
...
@@ -313,14 +312,15 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
tEncodeSize
(
tEncodeSSubmitReq2
,
pReq
,
len
,
terrno
);
if
(
TSDB_CODE_SUCCESS
==
terrno
)
{
SEncoder
encoder
;
len
+=
sizeof
(
S
MsgHead
);
len
+=
sizeof
(
S
SubmitReq2Msg
);
pBuf
=
rpcMallocCont
(
len
);
if
(
NULL
==
pBuf
)
{
goto
_end
;
}
((
SMsgHead
*
)
pBuf
)
->
vgId
=
TD_VID
(
pVnode
);
((
SMsgHead
*
)
pBuf
)
->
contLen
=
htonl
(
len
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SMsgHead
)),
len
-
sizeof
(
SMsgHead
));
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
vgId
=
TD_VID
(
pVnode
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
contLen
=
htonl
(
len
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
version
=
htobe64
(
1
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SSubmitReq2Msg
)),
len
-
sizeof
(
SSubmitReq2Msg
));
if
(
tEncodeSSubmitReq2
(
&
encoder
,
pReq
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
/*vError("failed to encode submit req since %s", terrstr());*/
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
6ecd5b29
...
...
@@ -683,13 +683,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
SPackedData
submit
=
{
.
msgStr
=
POINTER_SHIFT
(
pHead
->
body
,
sizeof
(
S
MsgHead
)),
.
msgLen
=
pHead
->
bodyLen
-
sizeof
(
S
MsgHead
),
.
msgStr
=
POINTER_SHIFT
(
pHead
->
body
,
sizeof
(
S
SubmitReq2Msg
)),
.
msgLen
=
pHead
->
bodyLen
-
sizeof
(
S
SubmitReq2Msg
),
.
ver
=
pHead
->
version
,
};
if
(
tqTaosxScanLog
(
pTq
,
pHandle
,
submit
,
&
taosxRsp
)
<
0
)
{
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
req
.
subKey
);
tqError
(
"tmq poll: tqTaosxScanLog error %"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
req
.
subKey
);
return
-
1
;
}
if
(
taosxRsp
.
blockNum
>
0
/* threshold */
)
{
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
6ecd5b29
...
...
@@ -207,8 +207,8 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
#endif
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
)
{
void
*
pReq
=
POINTER_SHIFT
(
msg
,
sizeof
(
S
MsgHead
));
int32_t
len
=
msgLen
-
sizeof
(
S
MsgHead
);
void
*
pReq
=
POINTER_SHIFT
(
msg
,
sizeof
(
S
SubmitReq2Msg
));
int32_t
len
=
msgLen
-
sizeof
(
S
SubmitReq2Msg
);
tqDebug
(
"vgId:%d, tq push msg ver %"
PRId64
", type: %s, p head %p, p body %p, len %d"
,
pTq
->
pVnode
->
config
.
vgId
,
ver
,
TMSG_INFO
(
msgType
),
msg
,
pReq
,
len
);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
6ecd5b29
...
...
@@ -311,8 +311,8 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
tqDebug
(
"return offset %"
PRId64
", no more valid"
,
ret
->
offset
.
version
);
return
-
1
;
}
void
*
body
=
POINTER_SHIFT
(
pReader
->
pWalReader
->
pHead
->
head
.
body
,
sizeof
(
S
MsgHead
));
int32_t
bodyLen
=
pReader
->
pWalReader
->
pHead
->
head
.
bodyLen
-
sizeof
(
S
MsgHead
);
void
*
body
=
POINTER_SHIFT
(
pReader
->
pWalReader
->
pHead
->
head
.
body
,
sizeof
(
S
SubmitReq2Msg
));
int32_t
bodyLen
=
pReader
->
pWalReader
->
pHead
->
head
.
bodyLen
-
sizeof
(
S
SubmitReq2Msg
);
int64_t
ver
=
pReader
->
pWalReader
->
pHead
->
head
.
version
;
#if 0
if (pReader->pWalReader->pHead->head.msgType != TDMT_VND_SUBMIT) {
...
...
@@ -560,7 +560,7 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pReader
->
submit
.
aSubmitTbData
,
pReader
->
nextBlk
);
pReader
->
nextBlk
++
;
if
(
pSubmitTbDataRet
)
*
pSubmitTbDataRet
=
pSubmitTbData
;
if
(
pSubmitTbDataRet
)
*
pSubmitTbDataRet
=
pSubmitTbData
;
int32_t
sversion
=
pSubmitTbData
->
sver
;
int64_t
suid
=
pSubmitTbData
->
suid
;
int64_t
uid
=
pSubmitTbData
->
uid
;
...
...
@@ -1012,7 +1012,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pReader
->
submit
.
aSubmitTbData
,
pReader
->
nextBlk
);
pReader
->
nextBlk
++
;
if
(
pSubmitTbDataRet
)
*
pSubmitTbDataRet
=
pSubmitTbData
;
if
(
pSubmitTbDataRet
)
*
pSubmitTbDataRet
=
pSubmitTbData
;
int32_t
sversion
=
pSubmitTbData
->
sver
;
int64_t
suid
=
pSubmitTbData
->
suid
;
int64_t
uid
=
pSubmitTbData
->
uid
;
...
...
@@ -1064,7 +1064,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
i
++
)
{
bool
buildNew
=
false
;
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
j
++
){
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
j
++
)
{
SColData
*
pCol
=
taosArrayGet
(
pCols
,
j
);
SColVal
colVal
;
tColDataGetValue
(
pCol
,
i
,
&
colVal
);
...
...
@@ -1089,7 +1089,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
SSDataBlock
block
=
{
0
};
SSchemaWrapper
*
pSW
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pSW
==
NULL
)
{
if
(
pSW
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
FAIL
;
}
...
...
@@ -1161,7 +1161,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
SRow
*
pRow
=
taosArrayGetP
(
pRows
,
i
);
bool
buildNew
=
false
;
for
(
int32_t
j
=
0
;
j
<
pTschema
->
numOfCols
;
j
++
){
for
(
int32_t
j
=
0
;
j
<
pTschema
->
numOfCols
;
j
++
)
{
SColVal
colVal
;
tRowGet
(
pRow
,
pTschema
,
j
,
&
colVal
);
if
(
curRow
==
0
)
{
...
...
@@ -1185,7 +1185,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
SSDataBlock
block
=
{
0
};
SSchemaWrapper
*
pSW
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pSW
==
NULL
)
{
if
(
pSW
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
FAIL
;
}
...
...
@@ -1256,7 +1256,7 @@ int32_t tqRetrieveTaosxBlock2(STqReader* pReader, SArray* blocks, SArray* schema
taosMemoryFree
(
assigned
);
return
0
;
FAIL:
FAIL:
taosMemoryFree
(
assigned
);
return
-
1
;
}
...
...
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
6ecd5b29
...
...
@@ -71,7 +71,6 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
return
0
;
}
void
tqSinkToTablePipeline
(
SStreamTask
*
pTask
,
void
*
vnode
,
int64_t
ver
,
void
*
data
)
{
const
SArray
*
pBlocks
=
(
const
SArray
*
)
data
;
SVnode
*
pVnode
=
(
SVnode
*
)
vnode
;
...
...
@@ -340,7 +339,7 @@ static int32_t encodeCreateChildTableForRPC(SVCreateTbBatchReq* pReqs, int32_t v
((
SMsgHead
*
)(
*
pBuf
))
->
vgId
=
vgId
;
((
SMsgHead
*
)(
*
pBuf
))
->
contLen
=
htonl
(
*
contLen
);
SEncoder
coder
=
{
0
};
tEncoderInit
(
&
coder
,
POINTER_SHIFT
(
*
pBuf
,
sizeof
(
SMsgHead
)),
(
*
contLen
)
-
sizeof
(
SMsgHead
)
);
tEncoderInit
(
&
coder
,
POINTER_SHIFT
(
*
pBuf
,
sizeof
(
SMsgHead
)),
(
*
contLen
)
-
sizeof
(
SMsgHead
)
);
if
(
tEncodeSVCreateTbBatchReq
(
&
coder
,
pReqs
)
<
0
)
{
rpcFreeCont
(
*
pBuf
);
*
pBuf
=
NULL
;
...
...
@@ -648,7 +647,7 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
if
(
IS_SET_NULL
(
pCol
))
{
SColVal
cv
=
COL_VAL_NULL
(
pCol
->
colId
,
pCol
->
type
);
taosArrayPush
(
pVals
,
&
cv
);
}
else
{
}
else
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
dataIndex
);
if
(
colDataIsNull_s
(
pColData
,
j
))
{
SColVal
cv
=
COL_VAL_NULL
(
pCol
->
colId
,
pCol
->
type
);
...
...
@@ -692,14 +691,15 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
int32_t
code
;
tEncodeSize
(
tEncodeSSubmitReq2
,
&
submitReq
,
len
,
code
);
SEncoder
encoder
;
len
+=
sizeof
(
S
MsgHead
);
len
+=
sizeof
(
S
SubmitReq2Msg
);
pBuf
=
rpcMallocCont
(
len
);
if
(
NULL
==
pBuf
)
{
goto
_end
;
}
((
SMsgHead
*
)
pBuf
)
->
vgId
=
TD_VID
(
pVnode
);
((
SMsgHead
*
)
pBuf
)
->
contLen
=
htonl
(
len
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SMsgHead
)),
len
-
sizeof
(
SMsgHead
));
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
vgId
=
TD_VID
(
pVnode
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
contLen
=
htonl
(
len
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
version
=
htobe64
(
1
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SSubmitReq2Msg
)),
len
-
sizeof
(
SSubmitReq2Msg
));
if
(
tEncodeSSubmitReq2
(
&
encoder
,
&
submitReq
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"failed to encode submit req since %s"
,
terrstr
());
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
6ecd5b29
...
...
@@ -201,7 +201,7 @@ static int32_t vnodePreProcessSubmitMsg(SVnode *pVnode, SRpcMsg *pMsg) {
SDecoder
*
pCoder
=
&
(
SDecoder
){
0
};
tDecoderInit
(
pCoder
,
(
uint8_t
*
)
pMsg
->
pCont
+
sizeof
(
S
MsgHead
),
pMsg
->
contLen
-
sizeof
(
SMsgHead
));
tDecoderInit
(
pCoder
,
(
uint8_t
*
)
pMsg
->
pCont
+
sizeof
(
S
SubmitReq2Msg
),
pMsg
->
contLen
-
sizeof
(
SSubmitReq2Msg
));
if
(
tStartDecode
(
pCoder
)
<
0
)
{
code
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -356,7 +356,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
break
;
/* TSDB */
case
TDMT_VND_SUBMIT
:
if
(
vnodeProcessSubmitReq
(
pVnode
,
version
,
p
Req
,
l
en
,
pRsp
)
<
0
)
goto
_err
;
if
(
vnodeProcessSubmitReq
(
pVnode
,
version
,
p
Msg
->
pCont
,
pMsg
->
contL
en
,
pRsp
)
<
0
)
goto
_err
;
break
;
case
TDMT_VND_DELETE
:
if
(
vnodeProcessDeleteReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
)
<
0
)
goto
_err
;
...
...
@@ -981,6 +981,186 @@ static int32_t vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock,
return
TSDB_CODE_SUCCESS
;
}
typedef
struct
SSubmitReqConvertCxt
{
SSubmitMsgIter
msgIter
;
SSubmitBlk
*
pBlock
;
SSubmitBlkIter
blkIter
;
STSRow
*
pRow
;
STSRowIter
rowIter
;
SSubmitTbData
*
pTbData
;
STSchema
*
pTbSchema
;
SArray
*
pColValues
;
}
SSubmitReqConvertCxt
;
static
int32_t
vnodeResetTableCxt
(
SMeta
*
pMeta
,
SSubmitReqConvertCxt
*
pCxt
)
{
taosMemoryFreeClear
(
pCxt
->
pTbSchema
);
pCxt
->
pTbSchema
=
metaGetTbTSchema
(
pMeta
,
pCxt
->
msgIter
.
suid
,
pCxt
->
msgIter
.
sversion
,
1
);
if
(
NULL
==
pCxt
->
pTbSchema
)
{
return
TSDB_CODE_INVALID_MSG
;
}
tdSTSRowIterInit
(
&
pCxt
->
rowIter
,
pCxt
->
pTbSchema
);
tDestroySSubmitTbData
(
pCxt
->
pTbData
,
TSDB_MSG_FLG_ENCODE
);
if
(
NULL
==
pCxt
->
pTbData
)
{
pCxt
->
pTbData
=
taosMemoryCalloc
(
1
,
sizeof
(
SSubmitTbData
));
if
(
NULL
==
pCxt
->
pTbData
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pTbData
->
flags
=
0
;
pCxt
->
pTbData
->
suid
=
pCxt
->
msgIter
.
suid
;
pCxt
->
pTbData
->
uid
=
pCxt
->
msgIter
.
uid
;
pCxt
->
pTbData
->
sver
=
pCxt
->
msgIter
.
sversion
;
pCxt
->
pTbData
->
pCreateTbReq
=
NULL
;
pCxt
->
pTbData
->
aRowP
=
taosArrayInit
(
128
,
POINTER_BYTES
);
if
(
NULL
==
pCxt
->
pTbData
->
aRowP
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
taosArrayDestroy
(
pCxt
->
pColValues
);
pCxt
->
pColValues
=
taosArrayInit
(
pCxt
->
pTbSchema
->
numOfCols
,
sizeof
(
SColVal
));
if
(
NULL
==
pCxt
->
pColValues
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
pCxt
->
pTbSchema
->
numOfCols
;
++
i
)
{
SColVal
val
=
COL_VAL_NONE
(
pCxt
->
pTbSchema
->
columns
[
i
].
colId
,
pCxt
->
pTbSchema
->
columns
[
i
].
type
);
taosArrayPush
(
pCxt
->
pColValues
,
&
val
);
}
return
TSDB_CODE_SUCCESS
;
}
static
void
vnodeDestroySubmitReqConvertCxt
(
SSubmitReqConvertCxt
*
pCxt
)
{
taosMemoryFreeClear
(
pCxt
->
pTbSchema
);
tDestroySSubmitTbData
(
pCxt
->
pTbData
,
TSDB_MSG_FLG_ENCODE
);
taosMemoryFreeClear
(
pCxt
->
pTbData
);
taosArrayDestroy
(
pCxt
->
pColValues
);
}
static
int32_t
vnodeCellValConvertToColVal
(
STColumn
*
pCol
,
SCellVal
*
pCellVal
,
SColVal
*
pColVal
)
{
if
(
tdValTypeIsNone
(
pCellVal
->
valType
))
{
pColVal
->
flag
=
CV_FLAG_NONE
;
return
TSDB_CODE_SUCCESS
;
}
if
(
tdValTypeIsNull
(
pCellVal
->
valType
))
{
pColVal
->
flag
=
CV_FLAG_NULL
;
return
TSDB_CODE_SUCCESS
;
}
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pColVal
->
value
.
nData
=
varDataLen
(
pCellVal
->
val
);
pColVal
->
value
.
pData
=
varDataVal
(
pCellVal
->
val
);
}
else
if
(
TSDB_DATA_TYPE_FLOAT
==
pCol
->
type
)
{
float
f
=
GET_FLOAT_VAL
(
pCellVal
->
val
);
memcpy
(
&
pColVal
->
value
.
val
,
&
f
,
sizeof
(
f
));
}
else
if
(
TSDB_DATA_TYPE_DOUBLE
==
pCol
->
type
)
{
pColVal
->
value
.
val
=
*
(
int64_t
*
)
pCellVal
->
val
;
}
else
{
GET_TYPED_DATA
(
pColVal
->
value
.
val
,
int64_t
,
pCol
->
type
,
pCellVal
->
val
);
}
pColVal
->
flag
=
CV_FLAG_VALUE
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
vnodeTSRowConvertToColValArray
(
SSubmitReqConvertCxt
*
pCxt
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
tdSTSRowIterReset
(
&
pCxt
->
rowIter
,
pCxt
->
pRow
);
for
(
int32_t
i
=
0
;
TSDB_CODE_SUCCESS
==
code
&&
i
<
pCxt
->
pTbSchema
->
numOfCols
;
++
i
)
{
STColumn
*
pCol
=
pCxt
->
pTbSchema
->
columns
+
i
;
SCellVal
cellVal
=
{
0
};
if
(
!
tdSTSRowIterFetch
(
&
pCxt
->
rowIter
,
pCol
->
colId
,
pCol
->
type
,
&
cellVal
))
{
break
;
}
code
=
vnodeCellValConvertToColVal
(
pCol
,
&
cellVal
,
(
SColVal
*
)
taosArrayGet
(
pCxt
->
pColValues
,
i
));
}
return
code
;
}
static
int32_t
vnodeDecodeCreateTbReq
(
SSubmitReqConvertCxt
*
pCxt
)
{
if
(
pCxt
->
msgIter
.
schemaLen
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
pCxt
->
pTbData
->
pCreateTbReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVCreateTbReq
));
if
(
NULL
==
pCxt
->
pTbData
->
pCreateTbReq
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
pCxt
->
pBlock
->
data
,
pCxt
->
msgIter
.
schemaLen
);
int32_t
code
=
tDecodeSVCreateTbReq
(
&
decoder
,
pCxt
->
pTbData
->
pCreateTbReq
);
tDecoderClear
(
&
decoder
);
return
code
;
}
static
int32_t
vnodeSubmitReqConvertToSubmitReq2
(
SVnode
*
pVnode
,
SSubmitReq
*
pReq
,
SSubmitReq2
*
pReq2
)
{
pReq2
->
aSubmitTbData
=
taosArrayInit
(
128
,
sizeof
(
SSubmitTbData
));
if
(
NULL
==
pReq2
->
aSubmitTbData
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SSubmitReqConvertCxt
cxt
=
{
0
};
int32_t
code
=
tInitSubmitMsgIter
(
pReq
,
&
cxt
.
msgIter
);
while
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tGetSubmitMsgNext
(
&
cxt
.
msgIter
,
&
cxt
.
pBlock
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
==
cxt
.
pBlock
)
{
break
;
}
code
=
vnodeResetTableCxt
(
pVnode
->
pMeta
,
&
cxt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tInitSubmitBlkIter
(
&
cxt
.
msgIter
,
cxt
.
pBlock
,
&
cxt
.
blkIter
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
vnodeDecodeCreateTbReq
(
&
cxt
);
}
while
(
TSDB_CODE_SUCCESS
==
code
&&
(
cxt
.
pRow
=
tGetSubmitBlkNext
(
&
cxt
.
blkIter
))
!=
NULL
)
{
code
=
vnodeTSRowConvertToColValArray
(
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SRow
**
pNewRow
=
taosArrayReserve
(
cxt
.
pTbData
->
aRowP
,
1
);
code
=
tRowBuild
(
cxt
.
pColValues
,
cxt
.
pTbSchema
,
pNewRow
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
(
NULL
==
taosArrayPush
(
pReq2
->
aSubmitTbData
,
cxt
.
pTbData
)
?
TSDB_CODE_OUT_OF_MEMORY
:
TSDB_CODE_SUCCESS
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
taosMemoryFreeClear
(
cxt
.
pTbData
);
}
}
vnodeDestroySubmitReqConvertCxt
(
&
cxt
);
return
code
;
}
static
int32_t
vnodeRebuildSubmitReqMsg
(
SSubmitReq2
*
pSubmitReq
,
void
**
ppMsg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
char
*
pMsg
=
NULL
;
uint32_t
msglen
=
0
;
tEncodeSize
(
tEncodeSSubmitReq2
,
pSubmitReq
,
msglen
,
code
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMsg
=
taosMemoryMalloc
(
msglen
);
if
(
NULL
==
pMsg
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SEncoder
encoder
;
tEncoderInit
(
&
encoder
,
pMsg
,
msglen
);
code
=
tEncodeSSubmitReq2
(
&
encoder
,
pSubmitReq
);
tEncoderClear
(
&
encoder
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
ppMsg
=
pMsg
;
}
return
code
;
}
static
int32_t
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
int32_t
code
=
0
;
terrno
=
0
;
...
...
@@ -993,7 +1173,19 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
pRsp
->
code
=
TSDB_CODE_SUCCESS
;
SSubmitReq2Msg
*
pMsg
=
(
SSubmitReq2Msg
*
)
pReq
;
if
(
0
==
pMsg
->
version
)
{
code
=
vnodeSubmitReqConvertToSubmitReq2
(
pVnode
,
(
SSubmitReq
*
)
pMsg
,
pSubmitReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
vnodeRebuildSubmitReqMsg
(
pSubmitReq
,
&
pReq
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
goto
_exit
;
}
}
else
{
// decode
pReq
=
POINTER_SHIFT
(
pReq
,
sizeof
(
SSubmitReq2Msg
));
len
-=
sizeof
(
SSubmitReq2Msg
);
SDecoder
dc
=
{
0
};
tDecoderInit
(
&
dc
,
pReq
,
len
);
if
(
tDecodeSSubmitReq2
(
&
dc
,
pSubmitReq
)
<
0
)
{
...
...
@@ -1001,6 +1193,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
goto
_exit
;
}
tDecoderClear
(
&
dc
);
}
for
(
int32_t
i
=
0
;
i
<
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pSubmitReq
->
aSubmitTbData
,
i
);
...
...
@@ -1140,11 +1333,15 @@ _exit:
// clear
taosArrayDestroy
(
newTbUids
);
tDestroySSubmitReq2
(
pSubmitReq
,
TSDB_MSG_FLG_DECODE
);
tDestroySSubmitReq2
(
pSubmitReq
,
0
==
pMsg
->
version
?
TSDB_MSG_FLG_CMPT
:
TSDB_MSG_FLG_DECODE
);
tDestroySSubmitRsp2
(
pSubmitRsp
,
TSDB_MSG_FLG_ENCODE
);
if
(
code
)
terrno
=
code
;
if
(
0
==
pMsg
->
version
)
{
taosMemoryFree
(
pReq
);
}
return
code
;
}
...
...
source/libs/executor/src/dataInserter.c
浏览文件 @
6ecd5b29
...
...
@@ -129,14 +129,15 @@ static int32_t submitReqToMsg(int32_t vgId, SSubmitReq2* pReq, void** pData, int
tEncodeSize
(
tEncodeSSubmitReq2
,
pReq
,
len
,
code
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SEncoder
encoder
;
len
+=
sizeof
(
S
MsgHead
);
len
+=
sizeof
(
S
SubmitReq2Msg
);
pBuf
=
taosMemoryMalloc
(
len
);
if
(
NULL
==
pBuf
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
((
SMsgHead
*
)
pBuf
)
->
vgId
=
htonl
(
vgId
);
((
SMsgHead
*
)
pBuf
)
->
contLen
=
htonl
(
len
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SMsgHead
)),
len
-
sizeof
(
SMsgHead
));
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
vgId
=
htonl
(
vgId
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
contLen
=
htonl
(
len
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
version
=
htobe64
(
1
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SSubmitReq2Msg
)),
len
-
sizeof
(
SSubmitReq2Msg
));
code
=
tEncodeSSubmitReq2
(
&
encoder
,
pReq
);
tEncoderClear
(
&
encoder
);
}
...
...
source/libs/parser/src/parInsertUtil.c
浏览文件 @
6ecd5b29
...
...
@@ -501,14 +501,15 @@ static int32_t buildSubmitReq(int32_t vgId, SSubmitReq2* pReq, void** pData, uin
tEncodeSize
(
tEncodeSSubmitReq2
,
pReq
,
len
,
code
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SEncoder
encoder
;
len
+=
sizeof
(
S
MsgHead
);
len
+=
sizeof
(
S
SubmitReq2Msg
);
pBuf
=
taosMemoryMalloc
(
len
);
if
(
NULL
==
pBuf
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
((
SMsgHead
*
)
pBuf
)
->
vgId
=
htonl
(
vgId
);
((
SMsgHead
*
)
pBuf
)
->
contLen
=
htonl
(
len
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SMsgHead
)),
len
-
sizeof
(
SMsgHead
));
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
vgId
=
htonl
(
vgId
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
header
.
contLen
=
htonl
(
len
);
((
SSubmitReq2Msg
*
)
pBuf
)
->
version
=
htobe64
(
1
);
tEncoderInit
(
&
encoder
,
POINTER_SHIFT
(
pBuf
,
sizeof
(
SSubmitReq2Msg
)),
len
-
sizeof
(
SSubmitReq2Msg
));
code
=
tEncodeSSubmitReq2
(
&
encoder
,
pReq
);
tEncoderClear
(
&
encoder
);
}
...
...
@@ -679,13 +680,12 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
pStart
+=
BitmapLen
(
numOfRows
);
}
char
*
pData
=
pStart
;
// uError("rawBlockBindData col bytes:%d, type:%d, size:%d, htonl size:%d", pColSchema->bytes, pColSchema->type, colLength[c], htonl(colLength[c]));
tColDataAddValueByDataBlock
(
pCol
,
pColSchema
->
type
,
pColSchema
->
bytes
,
numOfRows
,
offset
,
pData
);
fields
+=
sizeof
(
int8_t
)
+
sizeof
(
int32_t
);
if
(
needChangeLength
)
{
if
(
needChangeLength
)
{
pStart
+=
htonl
(
colLength
[
c
]);
}
else
{
}
else
{
pStart
+=
colLength
[
c
];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录