Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3d9cc764
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3d9cc764
编写于
12月 08, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add uid check
上级
a2092892
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
38 deletion
+60
-38
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+60
-38
未找到文件。
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
3d9cc764
...
...
@@ -750,12 +750,12 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
}
void
tqSinkToTablePipeline2
(
SStreamTask
*
pTask
,
void
*
vnode
,
int64_t
ver
,
void
*
data
)
{
const
SArray
*
pBlocks
=
(
const
SArray
*
)
data
;
SVnode
*
pVnode
=
(
SVnode
*
)
vnode
;
int64_t
suid
=
pTask
->
tbSink
.
stbUid
;
char
*
stbFullName
=
pTask
->
tbSink
.
stbFullName
;
STSchema
*
pTSchema
=
pTask
->
tbSink
.
pTSchema
;
SSchemaWrapper
*
pSchemaWrapper
=
pTask
->
tbSink
.
pSchemaWrapper
;
const
SArray
*
pBlocks
=
(
const
SArray
*
)
data
;
SVnode
*
pVnode
=
(
SVnode
*
)
vnode
;
int64_t
suid
=
pTask
->
tbSink
.
stbUid
;
char
*
stbFullName
=
pTask
->
tbSink
.
stbFullName
;
STSchema
*
pTSchema
=
pTask
->
tbSink
.
pTSchema
;
/*SSchemaWrapper* pSchemaWrapper = pTask->tbSink.pSchemaWrapper;*/
int32_t
blockSz
=
taosArrayGetSize
(
pBlocks
);
...
...
@@ -780,7 +780,6 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
}
for
(
int32_t
i
=
0
;
i
<
blockSz
;
i
++
)
{
bool
createTb
=
true
;
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
if
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_RESULT
)
{
SBatchDeleteReq
deleteReq
=
{
0
};
...
...
@@ -818,13 +817,31 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
tqDebug
(
"failed to put delete req into write-queue since %s"
,
terrstr
());
}
}
else
{
SSubmitTbData
*
pTbData
=
(
SSubmitTbData
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSubmitTbData
));
if
(
!
pTbData
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
SSubmitTbData
tbData
=
{
0
};
int32_t
rows
=
pDataBlock
->
info
.
rows
;
tqDebug
(
"tq sink, convert block1 %d, rows: %d"
,
i
,
rows
);
if
(
!
(
tbData
.
aRowP
=
taosArrayInit
(
rows
,
sizeof
(
SRow
*
))))
{
goto
_end
;
}
// create table req
if
(
createTb
)
{
tbData
.
suid
=
suid
;
tbData
.
uid
=
0
;
// uid is assigned by vnode
tbData
.
sver
=
pTSchema
->
version
;
char
*
ctbName
=
NULL
;
if
(
pDataBlock
->
info
.
parTbName
[
0
])
{
ctbName
=
strdup
(
pDataBlock
->
info
.
parTbName
);
}
else
{
ctbName
=
buildCtbNameByGroupId
(
stbFullName
,
pDataBlock
->
info
.
id
.
groupId
);
}
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mr
,
ctbName
)
<
0
)
{
metaReaderClear
(
&
mr
);
tqDebug
(
"vgId:%d, stream write into %s, table auto created"
,
TD_VID
(
pVnode
),
ctbName
);
SVCreateTbReq
*
pCreateTbReq
=
NULL
;
if
(
!
(
pCreateTbReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVCreateStbReq
))))
{
...
...
@@ -867,31 +884,36 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
pCreateTbReq
->
ctb
.
tagName
=
tagName
;
// set table name
if
(
pDataBlock
->
info
.
parTbName
[
0
])
{
pCreateTbReq
->
name
=
strdup
(
pDataBlock
->
info
.
parTbName
);
}
else
{
pCreateTbReq
->
name
=
buildCtbNameByGroupId
(
stbFullName
,
pDataBlock
->
info
.
id
.
groupId
);
}
pTbData
->
pCreateTbReq
=
pCreateTbReq
;
pTbData
->
flags
=
SUBMIT_REQ_AUTO_CREATE_TABLE
;
}
pCreateTbReq
->
name
=
ctbName
;
ctbName
=
NULL
;
pTbData
->
suid
=
suid
;
pTbData
->
uid
=
0
;
// uid is assigned by vnode
pTbData
->
sver
=
pTSchema
->
version
;
tbData
.
pCreateTbReq
=
pCreateTbReq
;
tbData
.
flags
=
SUBMIT_REQ_AUTO_CREATE_TABLE
;
}
else
{
if
(
mr
.
me
.
type
!=
TSDB_CHILD_TABLE
)
{
tqError
(
"vgId:%d, failed to write into %s, since table type incorrect, type %d"
,
TD_VID
(
pVnode
),
ctbName
,
mr
.
me
.
type
);
metaReaderClear
(
&
mr
);
taosMemoryFree
(
ctbName
);
continue
;
}
int32_t
rows
=
pDataBlock
->
info
.
rows
;
if
(
mr
.
me
.
ctbEntry
.
suid
!=
suid
)
{
tqError
(
"vgId:%d, failed to write into %s, since suid mismatch, expect suid: %"
PRId64
", actual suid %"
PRId64
""
,
TD_VID
(
pVnode
),
ctbName
,
suid
,
mr
.
me
.
ctbEntry
.
suid
);
metaReaderClear
(
&
mr
);
taosMemoryFree
(
ctbName
);
}
if
(
!
(
pTbData
->
aRowP
=
taosArrayInit
(
rows
,
sizeof
(
SRow
*
))))
{
taosMemoryFreeClear
(
pTbData
);
goto
_end
;
tbData
.
uid
=
mr
.
me
.
uid
;
metaReaderClear
(
&
mr
);
taosMemoryFreeClear
(
ctbName
)
;
}
tqDebug
(
"tq sink, convert block1 %d, rows: %d"
,
i
,
rows
);
// rows
if
(
!
pVals
&&
!
(
pVals
=
taosArrayInit
(
pTSchema
->
numOfCols
,
sizeof
(
SColVal
))))
{
taosArrayDestroy
(
pTbData
->
aRowP
);
taosMemoryFree
(
pTbData
);
taosArrayDestroy
(
tbData
.
aRowP
);
goto
_end
;
}
...
...
@@ -904,14 +926,15 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
SColVal
cv
=
COL_VAL_NULL
(
pCol
->
colId
,
pCol
->
type
);
taosArrayPush
(
pVals
,
&
cv
);
}
else
{
void
*
d
ata
=
colDataGetData
(
pColData
,
j
);
void
*
colD
ata
=
colDataGetData
(
pColData
,
j
);
if
(
IS_STR_DATA_TYPE
(
pCol
->
type
))
{
SValue
sv
=
(
SValue
){.
nData
=
varDataLen
(
data
),
.
pData
=
varDataVal
(
data
)};
// address copy, no value
SValue
sv
=
(
SValue
){.
nData
=
varDataLen
(
colData
),
.
pData
=
varDataVal
(
colData
)};
// address copy, no value
SColVal
cv
=
COL_VAL_VALUE
(
pCol
->
colId
,
pCol
->
type
,
sv
);
taosArrayPush
(
pVals
,
&
cv
);
}
else
{
SValue
sv
;
memcpy
(
&
sv
.
val
,
d
ata
,
tDataTypes
[
pCol
->
type
].
bytes
);
memcpy
(
&
sv
.
val
,
colD
ata
,
tDataTypes
[
pCol
->
type
].
bytes
);
SColVal
cv
=
COL_VAL_VALUE
(
pCol
->
colId
,
pCol
->
type
,
sv
);
taosArrayPush
(
pVals
,
&
cv
);
}
...
...
@@ -919,15 +942,14 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void*
}
SRow
*
pRow
=
NULL
;
if
((
terrno
=
tRowBuild
(
pVals
,
(
STSchema
*
)
pTSchema
,
&
pRow
))
<
0
)
{
tDestroySSubmitTbData
(
pT
bData
,
TSDB_MSG_FLG_ENCODE
);
tDestroySSubmitTbData
(
&
t
bData
,
TSDB_MSG_FLG_ENCODE
);
goto
_end
;
}
ASSERT
(
pRow
);
taosArrayPush
(
pTbData
->
aRowP
,
&
pRow
);
taosArrayPush
(
tbData
.
aRowP
,
&
pRow
);
}
taosArrayPush
(
pReq
->
aSubmitTbData
,
pTbData
);
taosMemoryFree
(
pTbData
);
taosArrayPush
(
pReq
->
aSubmitTbData
,
&
tbData
);
// encode
int32_t
len
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录