Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6c742829
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看板
未验证
提交
6c742829
编写于
6月 08, 2023
作者:
D
dapan1121
提交者:
GitHub
6月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21597 from taosdata/enh/TD-24586
enh: optimize filter performance
上级
240a7825
47c891fb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
107 addition
and
21 deletion
+107
-21
include/common/tcommon.h
include/common/tcommon.h
+1
-0
include/common/tdatablock.h
include/common/tdatablock.h
+1
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+89
-8
source/libs/executor/src/executorInt.c
source/libs/executor/src/executorInt.c
+1
-12
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+15
-1
未找到文件。
include/common/tcommon.h
浏览文件 @
6c742829
...
@@ -231,6 +231,7 @@ typedef struct SColumnInfoData {
...
@@ -231,6 +231,7 @@ typedef struct SColumnInfoData {
};
};
SColumnInfo
info
;
// column info
SColumnInfo
info
;
// column info
bool
hasNull
;
// if current column data has null value.
bool
hasNull
;
// if current column data has null value.
bool
reassigned
;
// if current column data is reassigned.
}
SColumnInfoData
;
}
SColumnInfoData
;
typedef
struct
SQueryTableDataCond
{
typedef
struct
SQueryTableDataCond
{
...
...
include/common/tdatablock.h
浏览文件 @
6c742829
...
@@ -178,6 +178,7 @@ int32_t getJsonValueLen(const char* data);
...
@@ -178,6 +178,7 @@ int32_t getJsonValueLen(const char* data);
int32_t
colDataSetVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataSetVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataReassignVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
dstRowIdx
,
uint32_t
srcRowIdx
,
const
char
*
pData
);
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
uint32_t
numOfRows
,
bool
trimValue
);
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
uint32_t
numOfRows
,
bool
trimValue
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRow1
,
int32_t
*
capacity
,
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRow2
);
const
SColumnInfoData
*
pSource
,
int32_t
numOfRow2
);
...
...
source/common/src/tdatablock.c
浏览文件 @
6c742829
...
@@ -23,6 +23,20 @@
...
@@ -23,6 +23,20 @@
int32_t
colDataGetLength
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
)
{
int32_t
colDataGetLength
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
if
(
pColumnInfoData
->
reassigned
)
{
int32_t
totalSize
=
0
;
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pColumnInfoData
->
pData
+
pColumnInfoData
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
totalSize
+=
colSize
;
}
return
totalSize
;
}
return
pColumnInfoData
->
varmeta
.
length
;
return
pColumnInfoData
->
varmeta
.
length
;
}
else
{
}
else
{
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_NULL
)
{
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_NULL
)
{
...
@@ -126,6 +140,29 @@ int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const
...
@@ -126,6 +140,29 @@ int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const
return
0
;
return
0
;
}
}
int32_t
colDataReassignVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
dstRowIdx
,
uint32_t
srcRowIdx
,
const
char
*
pData
)
{
int32_t
type
=
pColumnInfoData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
int32_t
dataLen
=
0
;
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
dataLen
=
getJsonValueLen
(
pData
);
}
else
{
dataLen
=
varDataTLen
(
pData
);
}
SVarColAttr
*
pAttr
=
&
pColumnInfoData
->
varmeta
;
pColumnInfoData
->
varmeta
.
offset
[
dstRowIdx
]
=
pColumnInfoData
->
varmeta
.
offset
[
srcRowIdx
];
pColumnInfoData
->
reassigned
=
true
;
}
else
{
memcpy
(
pColumnInfoData
->
pData
+
pColumnInfoData
->
info
.
bytes
*
dstRowIdx
,
pData
,
pColumnInfoData
->
info
.
bytes
);
colDataClearNull_f
(
pColumnInfoData
->
nullbitmap
,
dstRowIdx
);
}
return
0
;
}
int32_t
colDataReserve
(
SColumnInfoData
*
pColumnInfoData
,
size_t
newSize
)
{
int32_t
colDataReserve
(
SColumnInfoData
*
pColumnInfoData
,
size_t
newSize
)
{
if
(
!
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
if
(
!
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -580,8 +617,22 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
...
@@ -580,8 +617,22 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
*
(
int32_t
*
)
pStart
=
dataSize
;
*
(
int32_t
*
)
pStart
=
dataSize
;
pStart
+=
sizeof
(
int32_t
);
pStart
+=
sizeof
(
int32_t
);
memcpy
(
pStart
,
pCol
->
pData
,
dataSize
);
if
(
pCol
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
pStart
+=
dataSize
;
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
char
*
pColData
=
pCol
->
pData
+
pCol
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
memcpy
(
pStart
,
pColData
,
colSize
);
pStart
+=
colSize
;
}
}
else
{
memcpy
(
pStart
,
pCol
->
pData
,
dataSize
);
pStart
+=
dataSize
;
}
}
}
return
0
;
return
0
;
...
@@ -1741,7 +1792,20 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
...
@@ -1741,7 +1792,20 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
int32_t
len
=
colDataGetLength
(
pColData
,
rows
);
int32_t
len
=
colDataGetLength
(
pColData
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
len
);
tlen
+=
taosEncodeFixedI32
(
buf
,
len
);
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
pData
,
len
);
if
(
pColData
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pColData
->
info
.
type
))
{
for
(
int32_t
row
=
0
;
row
<
rows
;
++
row
)
{
char
*
pData
=
pColData
->
pData
+
pColData
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pData
);
}
else
{
colSize
=
varDataTLen
(
pData
);
}
tlen
+=
taosEncodeBinary
(
buf
,
pData
,
colSize
);
}
}
else
{
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
pData
,
len
);
}
}
}
return
tlen
;
return
tlen
;
}
}
...
@@ -2502,12 +2566,29 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
...
@@ -2502,12 +2566,29 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
data
+=
metaSize
;
data
+=
metaSize
;
dataLen
+=
metaSize
;
dataLen
+=
metaSize
;
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
if
(
pColRes
->
reassigned
&&
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
dataLen
+=
colSizes
[
col
];
colSizes
[
col
]
=
0
;
if
(
pColRes
->
pData
!=
NULL
)
{
for
(
int32_t
row
=
0
;
row
<
numOfRows
;
++
row
)
{
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
char
*
pColData
=
pColRes
->
pData
+
pColRes
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
pColRes
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
colSizes
[
col
]
+=
colSize
;
dataLen
+=
colSize
;
memmove
(
data
,
pColData
,
colSize
);
data
+=
colSize
;
}
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
dataLen
+=
colSizes
[
col
];
if
(
pColRes
->
pData
!=
NULL
)
{
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
}
data
+=
colSizes
[
col
];
}
}
data
+=
colSizes
[
col
];
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type, htonl(colSizes[col]), colSizes[col]);
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type, htonl(colSizes[col]), colSizes[col]);
...
...
source/libs/executor/src/executorInt.c
浏览文件 @
6c742829
...
@@ -562,7 +562,6 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
...
@@ -562,7 +562,6 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pDst
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pDst
->
info
.
type
))
{
int32_t
j
=
0
;
int32_t
j
=
0
;
pDst
->
varmeta
.
length
=
0
;
while
(
j
<
totalRows
)
{
while
(
j
<
totalRows
)
{
if
(
pIndicator
[
j
]
==
0
)
{
if
(
pIndicator
[
j
]
==
0
)
{
...
@@ -573,18 +572,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
...
@@ -573,18 +572,8 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD
if
(
colDataIsNull_var
(
pDst
,
j
))
{
if
(
colDataIsNull_var
(
pDst
,
j
))
{
colDataSetNull_var
(
pDst
,
numOfRows
);
colDataSetNull_var
(
pDst
,
numOfRows
);
}
else
{
}
else
{
// fix address sanitizer error. p1 may point to memory that will change during realloc of colDataSetVal, first copy it to p2
char
*
p1
=
colDataGetVarData
(
pDst
,
j
);
char
*
p1
=
colDataGetVarData
(
pDst
,
j
);
int32_t
len
=
0
;
colDataReassignVal
(
pDst
,
numOfRows
,
j
,
p1
);
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
len
=
getJsonValueLen
(
p1
);
}
else
{
len
=
varDataTLen
(
p1
);
}
char
*
p2
=
taosMemoryMalloc
(
len
);
memcpy
(
p2
,
p1
,
len
);
colDataSetVal
(
pDst
,
numOfRows
,
p2
,
false
);
taosMemoryFree
(
p2
);
}
}
numOfRows
+=
1
;
numOfRows
+=
1
;
j
+=
1
;
j
+=
1
;
...
...
source/libs/function/src/tudf.c
浏览文件 @
6c742829
...
@@ -791,7 +791,21 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo
...
@@ -791,7 +791,21 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo
memcpy
(
udfCol
->
colData
.
varLenCol
.
varOffsets
,
col
->
varmeta
.
offset
,
udfCol
->
colData
.
varLenCol
.
varOffsetsLen
);
memcpy
(
udfCol
->
colData
.
varLenCol
.
varOffsets
,
col
->
varmeta
.
offset
,
udfCol
->
colData
.
varLenCol
.
varOffsetsLen
);
udfCol
->
colData
.
varLenCol
.
payloadLen
=
colDataGetLength
(
col
,
udfBlock
->
numOfRows
);
udfCol
->
colData
.
varLenCol
.
payloadLen
=
colDataGetLength
(
col
,
udfBlock
->
numOfRows
);
udfCol
->
colData
.
varLenCol
.
payload
=
taosMemoryMalloc
(
udfCol
->
colData
.
varLenCol
.
payloadLen
);
udfCol
->
colData
.
varLenCol
.
payload
=
taosMemoryMalloc
(
udfCol
->
colData
.
varLenCol
.
payloadLen
);
memcpy
(
udfCol
->
colData
.
varLenCol
.
payload
,
col
->
pData
,
udfCol
->
colData
.
varLenCol
.
payloadLen
);
if
(
col
->
reassigned
)
{
for
(
int32_t
row
=
0
;
row
<
udfCol
->
colData
.
numOfRows
;
++
row
)
{
char
*
pColData
=
col
->
pData
+
col
->
varmeta
.
offset
[
row
];
int32_t
colSize
=
0
;
if
(
col
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
colSize
=
getJsonValueLen
(
pColData
);
}
else
{
colSize
=
varDataTLen
(
pColData
);
}
memcpy
(
udfCol
->
colData
.
varLenCol
.
payload
,
pColData
,
colSize
);
udfCol
->
colData
.
varLenCol
.
payload
+=
colSize
;
}
}
else
{
memcpy
(
udfCol
->
colData
.
varLenCol
.
payload
,
col
->
pData
,
udfCol
->
colData
.
varLenCol
.
payloadLen
);
}
}
else
{
}
else
{
udfCol
->
colData
.
fixLenCol
.
nullBitmapLen
=
BitmapLen
(
udfCol
->
colData
.
numOfRows
);
udfCol
->
colData
.
fixLenCol
.
nullBitmapLen
=
BitmapLen
(
udfCol
->
colData
.
numOfRows
);
int32_t
bitmapLen
=
udfCol
->
colData
.
fixLenCol
.
nullBitmapLen
;
int32_t
bitmapLen
=
udfCol
->
colData
.
fixLenCol
.
nullBitmapLen
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录