Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d625cc2e
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看板
提交
d625cc2e
编写于
7月 06, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: insert from query
上级
0d4fb5bb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
92 addition
and
86 deletion
+92
-86
include/common/tdatablock.h
include/common/tdatablock.h
+0
-2
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/executor/dataSinkMgt.h
include/libs/executor/dataSinkMgt.h
+1
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+0
-72
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-1
source/libs/executor/src/dataInserter.c
source/libs/executor/src/dataInserter.c
+71
-0
source/libs/executor/src/dataSinkMgt.c
source/libs/executor/src/dataSinkMgt.c
+1
-1
source/libs/qworker/inc/qwInt.h
source/libs/qworker/inc/qwInt.h
+1
-0
source/libs/qworker/inc/qwMsg.h
source/libs/qworker/inc/qwMsg.h
+1
-1
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+7
-4
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+7
-3
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+1
-1
未找到文件。
include/common/tdatablock.h
浏览文件 @
d625cc2e
...
...
@@ -246,8 +246,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
char
*
buildCtbNameByGroupId
(
const
char
*
stbName
,
uint64_t
groupId
);
SSubmitReq
*
dataBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
int64_t
uid
,
int64_t
suid
,
int32_t
vgId
);
static
FORCE_INLINE
int32_t
blockGetEncodeSize
(
const
SSDataBlock
*
pBlock
)
{
return
blockDataGetSerialMetaSize
(
taosArrayGetSize
(
pBlock
->
pDataBlock
))
+
blockDataGetSize
(
pBlock
);
}
...
...
include/common/tmsg.h
浏览文件 @
d625cc2e
...
...
@@ -665,6 +665,7 @@ typedef struct {
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
int32_t
sversion
;
int32_t
tversion
;
int64_t
affectedRows
;
}
SQueryTableRsp
;
int32_t
tSerializeSQueryTableRsp
(
void
*
buf
,
int32_t
bufLen
,
SQueryTableRsp
*
pRsp
);
...
...
include/libs/executor/dataSinkMgt.h
浏览文件 @
d625cc2e
...
...
@@ -100,7 +100,7 @@ void dsEndPut(DataSinkHandle handle, uint64_t useconds);
* @param handle
* @param pLen data length
*/
void
dsGetDataLength
(
DataSinkHandle
handle
,
int
32
_t
*
pLen
,
bool
*
pQueryEnd
);
void
dsGetDataLength
(
DataSinkHandle
handle
,
int
64
_t
*
pLen
,
bool
*
pQueryEnd
);
/**
* Get data, the caller needs to allocate data memory.
...
...
source/common/src/tdatablock.c
浏览文件 @
d625cc2e
...
...
@@ -2106,75 +2106,3 @@ const char* blockDecode(SSDataBlock* pBlock, int32_t numOfCols, int32_t numOfRow
return
pStart
;
}
SSubmitReq
*
dataBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
int64_t
uid
,
int64_t
suid
,
int32_t
vgId
)
{
SSubmitReq
*
ret
=
NULL
;
int32_t
sz
=
taosArrayGetSize
(
pBlocks
);
// cal size
int32_t
cap
=
sizeof
(
SSubmitReq
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
// TODO min
int32_t
rowSize
=
pDataBlock
->
info
.
rowSize
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
cap
+=
sizeof
(
SSubmitBlk
)
+
rows
*
maxLen
;
}
// assign data
// TODO
ret
=
rpcMallocCont
(
cap
);
ret
->
header
.
vgId
=
vgId
;
ret
->
version
=
htonl
(
1
);
ret
->
length
=
sizeof
(
SSubmitReq
);
ret
->
numOfBlocks
=
htonl
(
sz
);
SSubmitBlk
*
blkHead
=
POINTER_SHIFT
(
ret
,
sizeof
(
SSubmitReq
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
blkHead
->
numOfRows
=
htons
(
pDataBlock
->
info
.
rows
);
blkHead
->
sversion
=
htonl
(
pTSchema
->
version
);
// TODO
blkHead
->
suid
=
htobe64
(
suid
);
blkHead
->
uid
=
htobe64
(
uid
);
blkHead
->
schemaLen
=
htonl
(
0
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
dataLen
=
0
;
STSRow
*
rowData
=
POINTER_SHIFT
(
blkHead
,
sizeof
(
SSubmitBlk
));
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pTSchema
->
version
);
tdSRowSetTpInfo
(
&
rb
,
pTSchema
->
numOfCols
,
pTSchema
->
flen
);
tdSRowResetBuf
(
&
rb
,
rowData
);
for
(
int32_t
k
=
0
;
k
<
pTSchema
->
numOfCols
;
k
++
)
{
const
STColumn
*
pColumn
=
&
pTSchema
->
columns
[
k
];
SColumnInfoData
*
pColData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
if
(
colDataIsNull_s
(
pColData
,
j
))
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NONE
,
NULL
,
false
,
pColumn
->
offset
,
k
);
}
else
{
void
*
data
=
colDataGetData
(
pColData
,
j
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
}
}
int32_t
rowLen
=
TD_ROW_LEN
(
rowData
);
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
dataLen
+=
rowLen
;
}
blkHead
->
dataLen
=
htonl
(
dataLen
);
ret
->
length
+=
sizeof
(
SSubmitBlk
)
+
dataLen
;
blkHead
=
POINTER_SHIFT
(
blkHead
,
sizeof
(
SSubmitBlk
)
+
dataLen
);
}
ret
->
length
=
htonl
(
ret
->
length
);
return
ret
;
}
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
d625cc2e
...
...
@@ -247,7 +247,7 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
case
TDMT_SCH_FETCH
:
return
qWorkerProcessFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
,
0
);
case
TDMT_SCH_FETCH_RSP
:
return
qWorkerProcess
FetchRsp
(
pVnode
,
pVnode
->
pQuery
,
pMsg
,
0
);
return
qWorkerProcess
RspMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
,
0
);
case
TDMT_SCH_CANCEL_TASK
:
return
qWorkerProcessCancelMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
,
0
);
case
TDMT_SCH_DROP_TASK
:
...
...
source/libs/executor/src/dataInserter.c
浏览文件 @
d625cc2e
...
...
@@ -136,6 +136,77 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs
}
SSubmitReq
*
dataBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
int64_t
uid
,
int64_t
suid
,
int32_t
vgId
)
{
SSubmitReq
*
ret
=
NULL
;
int32_t
sz
=
taosArrayGetSize
(
pBlocks
);
// cal size
int32_t
cap
=
sizeof
(
SSubmitReq
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
// TODO min
int32_t
rowSize
=
pDataBlock
->
info
.
rowSize
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
cap
+=
sizeof
(
SSubmitBlk
)
+
rows
*
maxLen
;
}
// assign data
// TODO
ret
=
rpcMallocCont
(
cap
);
ret
->
header
.
vgId
=
vgId
;
ret
->
version
=
htonl
(
1
);
ret
->
length
=
sizeof
(
SSubmitReq
);
ret
->
numOfBlocks
=
htonl
(
sz
);
SSubmitBlk
*
blkHead
=
POINTER_SHIFT
(
ret
,
sizeof
(
SSubmitReq
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
blkHead
->
numOfRows
=
htons
(
pDataBlock
->
info
.
rows
);
blkHead
->
sversion
=
htonl
(
pTSchema
->
version
);
// TODO
blkHead
->
suid
=
htobe64
(
suid
);
blkHead
->
uid
=
htobe64
(
uid
);
blkHead
->
schemaLen
=
htonl
(
0
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
dataLen
=
0
;
STSRow
*
rowData
=
POINTER_SHIFT
(
blkHead
,
sizeof
(
SSubmitBlk
));
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pTSchema
->
version
);
tdSRowSetTpInfo
(
&
rb
,
pTSchema
->
numOfCols
,
pTSchema
->
flen
);
tdSRowResetBuf
(
&
rb
,
rowData
);
for
(
int32_t
k
=
0
;
k
<
pTSchema
->
numOfCols
;
k
++
)
{
const
STColumn
*
pColumn
=
&
pTSchema
->
columns
[
k
];
SColumnInfoData
*
pColData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
if
(
colDataIsNull_s
(
pColData
,
j
))
{
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NONE
,
NULL
,
false
,
pColumn
->
offset
,
k
);
}
else
{
void
*
data
=
colDataGetData
(
pColData
,
j
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
}
}
int32_t
rowLen
=
TD_ROW_LEN
(
rowData
);
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
dataLen
+=
rowLen
;
}
blkHead
->
dataLen
=
htonl
(
dataLen
);
ret
->
length
+=
sizeof
(
SSubmitBlk
)
+
dataLen
;
blkHead
=
POINTER_SHIFT
(
blkHead
,
sizeof
(
SSubmitBlk
)
+
dataLen
);
}
ret
->
length
=
htonl
(
ret
->
length
);
return
ret
;
}
static
int32_t
putDataBlock
(
SDataSinkHandle
*
pHandle
,
const
SInputData
*
pInput
,
bool
*
pContinue
)
{
SDataInserterHandle
*
pInserter
=
(
SDataInserterHandle
*
)
pHandle
;
taosArrayPush
(
pInserter
->
pDataBlocks
,
pInput
->
pData
);
...
...
source/libs/executor/src/dataSinkMgt.c
浏览文件 @
d625cc2e
...
...
@@ -56,7 +56,7 @@ void dsEndPut(DataSinkHandle handle, uint64_t useconds) {
return
pHandleImpl
->
fEndPut
(
pHandleImpl
,
useconds
);
}
void
dsGetDataLength
(
DataSinkHandle
handle
,
int
32
_t
*
pLen
,
bool
*
pQueryEnd
)
{
void
dsGetDataLength
(
DataSinkHandle
handle
,
int
64
_t
*
pLen
,
bool
*
pQueryEnd
)
{
SDataSinkHandle
*
pHandleImpl
=
(
SDataSinkHandle
*
)
handle
;
pHandleImpl
->
fGetLen
(
pHandleImpl
,
pLen
,
pQueryEnd
);
}
...
...
source/libs/qworker/inc/qwInt.h
浏览文件 @
d625cc2e
...
...
@@ -139,6 +139,7 @@ typedef struct SQWTaskCtx {
bool
queryContinue
;
bool
queryInQueue
;
int32_t
rspCode
;
int64_t
affectedRows
;
// for insert ...select stmt
SRpcHandleInfo
ctrlConnInfo
;
SRpcHandleInfo
dataConnInfo
;
...
...
source/libs/qworker/inc/qwMsg.h
浏览文件 @
d625cc2e
...
...
@@ -39,7 +39,7 @@ int32_t qwBuildAndSendFetchRsp(SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, i
int32_t
code
);
void
qwBuildFetchRsp
(
void
*
msg
,
SOutputData
*
input
,
int32_t
len
,
bool
qComplete
);
int32_t
qwBuildAndSendCQueryMsg
(
QW_FPARAMS_DEF
,
SRpcHandleInfo
*
pConn
);
int32_t
qwBuildAndSendQueryRsp
(
int32_t
rspType
,
SRpcHandleInfo
*
pConn
,
int32_t
code
,
S
TbVerInfo
*
tbInfo
);
int32_t
qwBuildAndSendQueryRsp
(
int32_t
rspType
,
SRpcHandleInfo
*
pConn
,
int32_t
code
,
S
QWTaskCtx
*
ctx
);
int32_t
qwBuildAndSendExplainRsp
(
SRpcHandleInfo
*
pConn
,
SExplainExecInfo
*
execInfo
,
int32_t
num
);
void
qwFreeFetchRsp
(
void
*
msg
);
int32_t
qwMallocFetchRsp
(
int32_t
length
,
SRetrieveTableRsp
**
rsp
);
...
...
source/libs/qworker/src/qwMsg.c
浏览文件 @
d625cc2e
...
...
@@ -43,13 +43,16 @@ void qwFreeFetchRsp(void *msg) {
}
}
int32_t
qwBuildAndSendQueryRsp
(
int32_t
rspType
,
SRpcHandleInfo
*
pConn
,
int32_t
code
,
STbVerInfo
*
tbInfo
)
{
int32_t
qwBuildAndSendQueryRsp
(
int32_t
rspType
,
SRpcHandleInfo
*
pConn
,
int32_t
code
,
SQWTaskCtx
*
ctx
)
{
STbVerInfo
*
tbInfo
=
ctx
?
&
ctx
->
tbInfo
:
NULL
;
int64_t
affectedRows
=
ctx
?
ctx
->
affectedRows
:
0
;
SQueryTableRsp
*
pRsp
=
(
SQueryTableRsp
*
)
rpcMallocCont
(
sizeof
(
SQueryTableRsp
));
pRsp
->
code
=
code
;
pRsp
->
code
=
htonl
(
code
);
pRsp
->
affectedRows
=
htobe64
(
affectedRows
);
if
(
tbInfo
)
{
strcpy
(
pRsp
->
tbFName
,
tbInfo
->
tbFName
);
pRsp
->
sversion
=
tbInfo
->
sversion
;
pRsp
->
tversion
=
tbInfo
->
tversion
;
pRsp
->
sversion
=
htonl
(
tbInfo
->
sversion
)
;
pRsp
->
tversion
=
htonl
(
tbInfo
->
tversion
)
;
}
SRpcMsg
rpcRsp
=
{
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
d625cc2e
...
...
@@ -57,6 +57,10 @@ int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
connInfo
.
ahandle
=
NULL
;
QW_ERR_RET
(
qwBuildAndSendExplainRsp
(
&
connInfo
,
execInfo
,
resNum
));
}
if
(
!
ctx
->
needFetch
)
{
dsGetDataLength
(
ctx
->
sinkHandle
,
&
ctx
->
affectedRows
,
NULL
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -184,7 +188,7 @@ int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo)
}
int32_t
qwGetQueryResFromSink
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
,
int32_t
*
dataLen
,
void
**
rspMsg
,
SOutputData
*
pOutput
)
{
int
32
_t
len
=
0
;
int
64
_t
len
=
0
;
SRetrieveTableRsp
*
rsp
=
NULL
;
bool
queryEnd
=
false
;
int32_t
code
=
0
;
...
...
@@ -243,7 +247,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
}
int32_t
qwGetDeleteResFromSink
(
QW_FPARAMS_DEF
,
SQWTaskCtx
*
ctx
,
int32_t
*
dataLen
,
void
**
rspMsg
,
SDeleteRes
*
pRes
)
{
int
32
_t
len
=
0
;
int
64
_t
len
=
0
;
SVDeleteRsp
rsp
=
{
0
};
bool
queryEnd
=
false
;
int32_t
code
=
0
;
...
...
@@ -445,7 +449,7 @@ _return:
}
if
(
rspConnection
)
{
qwBuildAndSendQueryRsp
(
input
->
msgType
+
1
,
rspConnection
,
code
,
ctx
?
&
ctx
->
tbInfo
:
NULL
);
qwBuildAndSendQueryRsp
(
input
->
msgType
+
1
,
rspConnection
,
code
,
ctx
);
QW_TASK_DLOG
(
"query msg rsped, handle:%p, code:%x - %s"
,
rspConnection
->
handle
,
code
,
tstrerror
(
code
));
}
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
d625cc2e
...
...
@@ -331,7 +331,7 @@ void qwtEndPut(DataSinkHandle handle, uint64_t useconds) {
qwtTestSinkQueryEnd
=
true
;
}
void
qwtGetDataLength
(
DataSinkHandle
handle
,
int
32
_t
*
pLen
,
bool
*
pQueryEnd
)
{
void
qwtGetDataLength
(
DataSinkHandle
handle
,
int
64
_t
*
pLen
,
bool
*
pQueryEnd
)
{
static
int32_t
in
=
0
;
if
(
in
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录