Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1c5c4a1d
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看板
提交
1c5c4a1d
编写于
7月 21, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: merge dup rows in client
上级
dd6aa40f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
13 deletion
+28
-13
source/libs/parser/src/parInsertData.c
source/libs/parser/src/parInsertData.c
+28
-13
未找到文件。
source/libs/parser/src/parInsertData.c
浏览文件 @
1c5c4a1d
...
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// clang-format o
n
// clang-format o
ff
#include "parInsertData.h"
#include "catalog.h"
...
...
@@ -37,14 +37,14 @@ typedef struct SBlockKeyInfo {
typedef
struct
{
int32_t
index
;
SArray
*
rowArray
;
// array of merged rows(mem allocated by tRealloc)
SArray
*
rowArray
;
// array of merged rows(mem allocated by tRealloc
/free by tFree
)
STSchema
*
pSchema
;
int64_t
tbUid
;
// suid for child table, uid for normal table
}
SBlockRowMerger
;
static
void
tdResetSBlockRowMerger
(
SBlockRowMerger
*
pMerger
)
{
static
FORCE_INLINE
void
tdResetSBlockRowMerger
(
SBlockRowMerger
*
pMerger
)
{
if
(
pMerger
)
{
pMerger
->
index
=
-
1
;
taosMemoryFreeClear
(
pMerger
->
pSchema
);
}
}
...
...
@@ -57,6 +57,7 @@ static void tdFreeSBlockRowMerger(SBlockRowMerger* pMerger) {
taosArrayDestroy
(
pMerger
->
rowArray
);
taosMemoryFreeClear
(
pMerger
->
pSchema
);
taosMemoryFree
(
pMerger
);
}
}
...
...
@@ -430,15 +431,15 @@ static void* tdGetCurRowFromBlockMerger(SBlockRowMerger* pBlkRowMerger) {
return
NULL
;
}
static
int32_t
tdBlockRowMerge
(
STable
DataBlocks
*
dataBuf
,
SBlockKeyTuple
*
pEndKeyTp
,
int32_t
nDupRows
,
static
int32_t
tdBlockRowMerge
(
STable
Meta
*
pTableMeta
,
SBlockKeyTuple
*
pEndKeyTp
,
int32_t
nDupRows
,
SBlockRowMerger
**
pBlkRowMerger
,
int32_t
rowSize
)
{
ASSERT
(
nDupRows
>
1
);
SBlockKeyTuple
*
pStartKeyTp
=
pEndKeyTp
-
(
nDupRows
-
1
);
ASSERT
(
pStartKeyTp
->
skey
==
pEndKeyTp
->
skey
);
STSRow
*
pEndRow
=
(
STSRow
*
)
pEndKeyTp
->
payloadAddr
;
// TODO: optimization if end row is all normal
#if 0
STSRow* pEndRow = (STSRow*)pEndKeyTp->payloadAddr;
if(isNormal(pEndRow)) { // set the end row if it is normal and return directly
pStartKeyTp->payloadAddr = pEndKeyTp->payloadAddr;
return TSDB_CODE_SUCCESS;
...
...
@@ -461,14 +462,25 @@ static int32_t tdBlockRowMerge(STableDataBlocks* dataBuf, SBlockKeyTuple* pEndKe
}
}
if
((
*
pBlkRowMerger
)
->
pSchema
)
{
if
((
*
pBlkRowMerger
)
->
pSchema
->
version
!=
pTableMeta
->
sversion
)
{
taosMemoryFreeClear
((
*
pBlkRowMerger
)
->
pSchema
);
}
else
{
if
((
*
pBlkRowMerger
)
->
tbUid
!=
(
pTableMeta
->
suid
>
0
?
pTableMeta
->
suid
:
pTableMeta
->
uid
))
{
taosMemoryFreeClear
((
*
pBlkRowMerger
)
->
pSchema
);
}
}
}
if
(
!
(
*
pBlkRowMerger
)
->
pSchema
)
{
(
*
pBlkRowMerger
)
->
pSchema
=
tdGetSTSChemaFromSSChema
(
dataBuf
->
pTableMeta
->
schema
,
dataBuf
->
pTableMeta
->
tableInfo
.
numOfColumns
,
dataBuf
->
pTableMeta
->
sversion
);
(
*
pBlkRowMerger
)
->
pSchema
=
tdGetSTSChemaFromSSChema
(
pTableMeta
->
schema
,
pTableMeta
->
tableInfo
.
numOfColumns
,
pTableMeta
->
sversion
);
if
(
!
(
*
pBlkRowMerger
)
->
pSchema
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
(
*
pBlkRowMerger
)
->
tbUid
=
pTableMeta
->
suid
>
0
?
pTableMeta
->
suid
:
pTableMeta
->
uid
;
}
void
*
pDestRow
=
NULL
;
...
...
@@ -491,7 +503,7 @@ static int32_t tdBlockRowMerge(STableDataBlocks* dataBuf, SBlockKeyTuple* pEndKe
SArray
*
pArray
=
taosArrayInit
(
pSchema
->
numOfCols
,
sizeof
(
SColVal
));
for
(
int32_t
i
=
0
;
i
<
pSchema
->
numOfCols
;
++
i
)
{
SColVal
colVal
=
{
0
};
for
(
int32_t
j
=
0
;
j
<
nDupRows
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
nDupRows
;
++
j
)
{
tTSRowGetVal
((
pEndKeyTp
-
j
)
->
payloadAddr
,
pSchema
,
i
,
&
colVal
);
if
(
!
colVal
.
isNone
)
{
break
;
...
...
@@ -512,6 +524,7 @@ static int32_t tdBlockRowMerge(STableDataBlocks* dataBuf, SBlockKeyTuple* pEndKe
static
int
sortMergeDataBlockDupRows
(
STableDataBlocks
*
dataBuf
,
SBlockKeyInfo
*
pBlkKeyInfo
,
SBlockRowMerger
**
ppBlkRowMerger
)
{
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)
dataBuf
->
pData
;
STableMeta
*
pTableMeta
=
dataBuf
->
pTableMeta
;
int16_t
nRows
=
pBlocks
->
numOfRows
;
// size is less than the total size, since duplicated rows may be removed.
...
...
@@ -566,11 +579,13 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p
}
if
((
j
-
i
)
>
1
)
{
if
(
tdBlockRowMerge
(
dataBuf
,
(
pBlkKeyTuple
+
j
-
1
),
j
-
i
,
ppBlkRowMerger
,
extendedRowSize
)
<
0
)
{
if
(
tdBlockRowMerge
(
pTableMeta
,
(
pBlkKeyTuple
+
j
-
1
),
j
-
i
,
ppBlkRowMerger
,
extendedRowSize
)
<
0
)
{
return
TSDB_CODE_FAILED
;
}
(
pBlkKeyTuple
+
nextPos
)
->
payloadAddr
=
tdGetCurRowFromBlockMerger
(
*
ppBlkRowMerger
);
hasDup
=
true
;
if
(
!
hasDup
)
{
hasDup
=
true
;
}
i
=
j
;
}
else
{
if
(
hasDup
)
{
...
...
@@ -585,7 +600,7 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p
if
((
j
-
i
)
>
1
)
{
ASSERT
((
pBlkKeyTuple
+
i
)
->
skey
==
(
pBlkKeyTuple
+
j
-
1
)
->
skey
);
if
(
tdBlockRowMerge
(
dataBuf
,
(
pBlkKeyTuple
+
j
-
1
),
j
-
i
,
ppBlkRowMerger
,
extendedRowSize
)
<
0
)
{
if
(
tdBlockRowMerge
(
pTableMeta
,
(
pBlkKeyTuple
+
j
-
1
),
j
-
i
,
ppBlkRowMerger
,
extendedRowSize
)
<
0
)
{
return
TSDB_CODE_FAILED
;
}
(
pBlkKeyTuple
+
nextPos
)
->
payloadAddr
=
tdGetCurRowFromBlockMerger
(
*
ppBlkRowMerger
);
...
...
@@ -594,7 +609,7 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p
}
dataBuf
->
ordered
=
true
;
pBlocks
->
numOfRows
=
i
+
1
;
pBlocks
->
numOfRows
=
nextPos
+
1
;
}
dataBuf
->
size
=
sizeof
(
SSubmitBlk
)
+
pBlocks
->
numOfRows
*
extendedRowSize
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录