Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e9fc109e
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
e9fc109e
编写于
1月 11, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): opt query perf.
上级
53f27901
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
18 deletion
+17
-18
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-4
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+13
-12
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+3
-2
未找到文件。
source/libs/executor/inc/executil.h
浏览文件 @
e9fc109e
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
typedef
struct
SGroupResInfo
{
typedef
struct
SGroupResInfo
{
int32_t
index
;
int32_t
index
;
SArray
*
pRows
;
// SArray<SResKeyPos>
SArray
*
pRows
;
// SArray<SResKeyPos>
char
*
pBuf
;
}
SGroupResInfo
;
}
SGroupResInfo
;
typedef
struct
SResultRow
{
typedef
struct
SResultRow
{
...
@@ -115,10 +116,6 @@ struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t i
...
@@ -115,10 +116,6 @@ struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t i
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
,
bool
forUpdate
)
{
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
,
bool
forUpdate
)
{
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
if
(
NULL
==
bufPage
)
{
return
NULL
;
}
if
(
forUpdate
)
{
if
(
forUpdate
)
{
setBufPageDirty
(
bufPage
,
true
);
setBufPageDirty
(
bufPage
,
true
);
}
}
...
...
source/libs/executor/src/executil.c
浏览文件 @
e9fc109e
...
@@ -89,13 +89,7 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
...
@@ -89,13 +89,7 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
}
}
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
)
{
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
)
{
assert
(
pGroupResInfo
!=
NULL
);
taosMemoryFreeClear
(
pGroupResInfo
->
pBuf
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pGroupResInfo
->
pRows
);
++
i
)
{
SResKeyPos
*
pRes
=
taosArrayGetP
(
pGroupResInfo
->
pRows
,
i
);
taosMemoryFree
(
pRes
);
}
pGroupResInfo
->
pRows
=
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
pGroupResInfo
->
pRows
=
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
}
}
...
@@ -126,20 +120,28 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
...
@@ -126,20 +120,28 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in
}
}
// extract the result rows information from the hash map
// extract the result rows information from the hash map
int32_t
size
=
tSimpleHashGetSize
(
pHashmap
);
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
pGroupResInfo
->
pRows
=
taosArrayInit
(
10
,
POINTER_BYTES
);
pGroupResInfo
->
pRows
=
taosArrayInit
(
size
,
POINTER_BYTES
);
// todo avoid repeated malloc memory
size_t
keyLen
=
0
;
size_t
keyLen
=
0
;
int32_t
iter
=
0
;
int32_t
num
=
0
,
iter
=
0
,
itemSize
=
0
;
while
((
pData
=
tSimpleHashIterate
(
pHashmap
,
pData
,
&
iter
))
!=
NULL
)
{
while
((
pData
=
tSimpleHashIterate
(
pHashmap
,
pData
,
&
iter
))
!=
NULL
)
{
void
*
key
=
tSimpleHashGetKey
(
pData
,
&
keyLen
);
void
*
key
=
tSimpleHashGetKey
(
pData
,
&
keyLen
);
SResKeyPos
*
p
=
taosMemoryMalloc
(
keyLen
+
sizeof
(
SResultRowPosition
));
if
(
pGroupResInfo
->
pBuf
==
NULL
)
{
itemSize
=
keyLen
+
sizeof
(
SResultRowPosition
);
pGroupResInfo
->
pBuf
=
taosMemoryMalloc
(
size
*
itemSize
);
}
SResKeyPos
*
p
=
(
SResKeyPos
*
)(
pGroupResInfo
->
pBuf
+
num
*
itemSize
);
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
memcpy
(
p
->
key
,
(
char
*
)
key
+
sizeof
(
uint64_t
),
keyLen
-
sizeof
(
uint64_t
));
memcpy
(
p
->
key
,
(
char
*
)
key
+
sizeof
(
uint64_t
),
keyLen
-
sizeof
(
uint64_t
));
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
p
);
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
p
);
}
}
...
@@ -172,7 +174,6 @@ bool hasRemainResults(SGroupResInfo* pGroupResInfo) {
...
@@ -172,7 +174,6 @@ bool hasRemainResults(SGroupResInfo* pGroupResInfo) {
}
}
int32_t
getNumOfTotalRes
(
SGroupResInfo
*
pGroupResInfo
)
{
int32_t
getNumOfTotalRes
(
SGroupResInfo
*
pGroupResInfo
)
{
assert
(
pGroupResInfo
!=
NULL
);
if
(
pGroupResInfo
->
pRows
==
0
)
{
if
(
pGroupResInfo
->
pRows
==
0
)
{
return
0
;
return
0
;
}
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e9fc109e
...
@@ -3392,9 +3392,11 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
...
@@ -3392,9 +3392,11 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
}
}
}
}
// the allocated memory comes from outer function.
void
initGroupResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
)
{
void
initGroupResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
)
{
pGroupResInfo
->
pRows
=
pArrayList
;
pGroupResInfo
->
pRows
=
pArrayList
;
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
pBuf
=
NULL
;
}
}
void
doBuildSessionResult
(
SOperatorInfo
*
pOperator
,
SStreamState
*
pState
,
SGroupResInfo
*
pGroupResInfo
,
void
doBuildSessionResult
(
SOperatorInfo
*
pOperator
,
SStreamState
*
pState
,
SGroupResInfo
*
pGroupResInfo
,
...
@@ -3405,8 +3407,7 @@ void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroup
...
@@ -3405,8 +3407,7 @@ void doBuildSessionResult(SOperatorInfo* pOperator, SStreamState* pState, SGroup
blockDataCleanup
(
pBlock
);
blockDataCleanup
(
pBlock
);
if
(
!
hasRemainResults
(
pGroupResInfo
))
{
if
(
!
hasRemainResults
(
pGroupResInfo
))
{
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
cleanupGroupResInfo
(
pGroupResInfo
);
pGroupResInfo
->
pRows
=
NULL
;
return
;
return
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录