Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
405c4c63
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
405c4c63
编写于
7月 16, 2022
作者:
H
Haojun Liao
提交者:
GitHub
7月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14991 from taosdata/feature/3_liaohj
fix(query):support multigroup in groupby operator.
上级
3d9756c1
6756c651
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
56 deletion
+41
-56
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+0
-3
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+5
-7
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+29
-40
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+2
-4
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+4
-1
tests/system-test/2-query/unique.py
tests/system-test/2-query/unique.py
+1
-1
未找到文件。
source/libs/executor/src/executil.c
浏览文件 @
405c4c63
...
...
@@ -115,9 +115,6 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
memcpy
(
p
->
key
,
(
char
*
)
key
+
sizeof
(
uint64_t
),
keyLen
-
sizeof
(
uint64_t
));
#ifdef BUF_PAGE_DEBUG
qDebug
(
"page_groupRes, groupId:%"
PRIu64
",pageId:%d,offset:%d
\n
"
,
p
->
groupId
,
p
->
pos
.
pageId
,
p
->
pos
.
offset
);
#endif
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
p
);
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
405c4c63
...
...
@@ -1506,15 +1506,11 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprI
int32_t
numOfExprs
)
{
int32_t
numOfRows
=
getNumOfTotalRes
(
pGroupResInfo
);
int32_t
start
=
pGroupResInfo
->
index
;
#ifdef BUF_PAGE_DEBUG
qDebug
(
"
\n
page_copytoblock rows:%d"
,
numOfRows
);
#endif
for
(
int32_t
i
=
start
;
i
<
numOfRows
;
i
+=
1
)
{
SResKeyPos
*
pPos
=
taosArrayGetP
(
pGroupResInfo
->
pRows
,
i
);
SFilePage
*
page
=
getBufPage
(
pBuf
,
pPos
->
pos
.
pageId
);
#ifdef BUF_PAGE_DEBUG
qDebug
(
"page_copytoblock pos pageId:%d, offset:%d"
,
pPos
->
pos
.
pageId
,
pPos
->
pos
.
offset
);
#endif
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
page
+
pPos
->
pos
.
offset
);
doUpdateNumOfRows
(
pRow
,
numOfExprs
,
rowCellOffset
);
...
...
@@ -2222,6 +2218,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
if
(
completed
==
totalSources
)
{
return
setAllSourcesCompleted
(
pOperator
,
startTs
);
}
sched_yield
();
}
_error:
...
...
@@ -3748,7 +3746,7 @@ void doDestroyExchangeOperatorInfo(void* param) {
taosArrayDestroy
(
pExInfo
->
pSources
);
taosArrayDestroy
(
pExInfo
->
pSourceDataInfo
);
if
(
pExInfo
->
pResult
!=
NULL
)
{
blockDataDestroy
(
pExInfo
->
pResult
);
pExInfo
->
pResult
=
blockDataDestroy
(
pExInfo
->
pResult
);
}
tsem_destroy
(
&
pExInfo
->
ready
);
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
405c4c63
...
...
@@ -29,7 +29,7 @@
static
void
*
getCurrentDataGroupInfo
(
const
SPartitionOperatorInfo
*
pInfo
,
SDataGroupInfo
**
pGroupInfo
,
int32_t
len
);
static
int32_t
*
setupColumnOffset
(
const
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
);
static
int32_t
setGroupResultOutputBuf
(
SOperatorInfo
*
pOperator
,
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
bytes
,
int32
_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SAggSupporter
*
pAggSup
);
uint64
_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SAggSupporter
*
pAggSup
);
static
void
destroyGroupOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
...
...
@@ -264,7 +264,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
setGroupResultOutputBuf
(
pOperator
,
&
(
pInfo
->
binfo
),
pOperator
->
exprSupp
.
numOfExprs
,
pInfo
->
keyBuf
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
&
pInfo
->
aggSup
);
int32_t
ret
=
setGroupResultOutputBuf
(
pOperator
,
&
(
pInfo
->
binfo
),
pOperator
->
exprSupp
.
numOfExprs
,
pInfo
->
keyBuf
,
len
,
pBlock
->
info
.
groupId
,
pInfo
->
aggSup
.
pResultBuf
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -282,7 +282,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
setGroupResultOutputBuf
(
pOperator
,
&
(
pInfo
->
binfo
),
pOperator
->
exprSupp
.
numOfExprs
,
pInfo
->
keyBuf
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
&
pInfo
->
aggSup
);
pBlock
->
info
.
groupId
,
pInfo
->
aggSup
.
pResultBuf
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -293,6 +293,29 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
}
static
SSDataBlock
*
buildGroupResultDataBlock
(
SOperatorInfo
*
pOperator
)
{
SGroupbyOperatorInfo
*
pInfo
=
pOperator
->
info
;
SSDataBlock
*
pRes
=
pInfo
->
binfo
.
pRes
;
while
(
1
)
{
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
bool
hasRemain
=
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
if
(
!
hasRemain
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
if
(
pRes
->
info
.
rows
>
0
)
{
break
;
}
}
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
return
(
pRes
->
info
.
rows
==
0
)
?
NULL
:
pRes
;
}
static
SSDataBlock
*
hashGroupbyAggregate
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -304,22 +327,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
SSDataBlock
*
pRes
=
pInfo
->
binfo
.
pRes
;
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
while
(
1
)
{
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
bool
hasRemain
=
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
if
(
!
hasRemain
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
if
(
pRes
->
info
.
rows
>
0
)
{
break
;
}
}
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
return
(
pRes
->
info
.
rows
==
0
)
?
NULL
:
pRes
;
return
buildGroupResultDataBlock
(
pOperator
);
}
int32_t
order
=
TSDB_ORDER_ASC
;
...
...
@@ -373,26 +381,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
initGroupedResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
0
);
pOperator
->
cost
.
openCost
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
while
(
1
)
{
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
bool
hasRemain
=
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
if
(
!
hasRemain
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
if
(
pRes
->
info
.
rows
>
0
)
{
break
;
}
}
size_t
rows
=
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
return
(
rows
==
0
)
?
NULL
:
pRes
;
return
buildGroupResultDataBlock
(
pOperator
);
}
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
...
...
@@ -800,7 +789,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
}
int32_t
setGroupResultOutputBuf
(
SOperatorInfo
*
pOperator
,
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
bytes
,
int32
_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SAggSupporter
*
pAggSup
)
{
uint64
_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SAggSupporter
*
pAggSup
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SqlFunctionCtx
*
pCtx
=
pOperator
->
exprSupp
.
pCtx
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
405c4c63
...
...
@@ -234,9 +234,9 @@ void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) {
SSortOperatorInfo
*
pInfo
=
(
SSortOperatorInfo
*
)
param
;
pInfo
->
binfo
.
pRes
=
blockDataDestroy
(
pInfo
->
binfo
.
pRes
);
tsortDestroySortHandle
(
pInfo
->
pSortHandle
);
taosArrayDestroy
(
pInfo
->
pSortInfo
);
taosArrayDestroy
(
pInfo
->
pColMatchInfo
);
taosMemoryFreeClear
(
param
);
}
...
...
@@ -539,14 +539,12 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
}
pInfo
->
startTs
=
taosGetTimestampUs
();
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pInputBlock
,
pTaskInfo
->
id
.
str
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
,
NULL
,
NULL
);
tsortSetCompareGroupId
(
pInfo
->
pSortHandle
,
pInfo
->
groupSort
);
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfDownstream
;
++
i
)
{
...
...
@@ -556,7 +554,6 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) {
}
int32_t
code
=
tsortOpen
(
pInfo
->
pSortHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
terrno
);
}
...
...
@@ -674,6 +671,7 @@ void destroyMultiwayMergeOperatorInfo(void* param, int32_t numOfOutput) {
pInfo
->
binfo
.
pRes
=
blockDataDestroy
(
pInfo
->
binfo
.
pRes
);
pInfo
->
pInputBlock
=
blockDataDestroy
(
pInfo
->
pInputBlock
);
tsortDestroySortHandle
(
pInfo
->
pSortHandle
);
taosArrayDestroy
(
pInfo
->
pSortInfo
);
taosArrayDestroy
(
pInfo
->
pColMatchInfo
);
...
...
source/libs/executor/src/tsort.c
浏览文件 @
405c4c63
...
...
@@ -109,6 +109,10 @@ static int32_t sortComparClearup(SMsortComparParam* cmpParam) {
}
void
tsortDestroySortHandle
(
SSortHandle
*
pSortHandle
)
{
if
(
pSortHandle
==
NULL
)
{
return
;
}
tsortClose
(
pSortHandle
);
if
(
pSortHandle
->
pMergeTree
!=
NULL
)
{
tMergeTreeDestroy
(
pSortHandle
->
pMergeTree
);
...
...
@@ -119,7 +123,6 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
blockDataDestroy
(
pSortHandle
->
pDataBlock
);
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pSortHandle
->
pOrderedSource
);
i
++
){
SSortSource
**
pSource
=
taosArrayGet
(
pSortHandle
->
pOrderedSource
,
i
);
blockDataDestroy
((
*
pSource
)
->
src
.
pBlock
);
taosMemoryFreeClear
(
*
pSource
);
}
taosArrayDestroy
(
pSortHandle
->
pOrderedSource
);
...
...
tests/system-test/2-query/unique.py
浏览文件 @
405c4c63
...
...
@@ -426,7 +426,7 @@ class TDTestCase:
tdSql
.
query
(
" select unique(t1+c1) from stb1 "
)
tdSql
.
checkRows
(
13
)
tdSql
.
query
(
" select unique(t1+c1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
13
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
" select unique(t1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录