Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
ea0b5b9b
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea0b5b9b
编写于
5月 31, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-4312]
上级
5262f927
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
48 deletion
+75
-48
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+54
-48
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+19
-0
未找到文件。
src/client/src/tscUtil.c
浏览文件 @
ea0b5b9b
...
...
@@ -646,9 +646,10 @@ static SColumnInfo* extractColumnInfoFromResult(SArray* pTableCols) {
}
typedef
struct
SDummyInputInfo
{
SSDataBlock
*
block
;
SSqlObj
*
pSql
;
// refactor: remove it
int32_t
numOfFilterCols
;
SSDataBlock
*
block
;
STableQueryInfo
*
pTableQueryInfo
;
SSqlObj
*
pSql
;
// refactor: remove it
int32_t
numOfFilterCols
;
SSingleColumnFilterInfo
*
pFilterInfo
;
}
SDummyInputInfo
;
...
...
@@ -665,7 +666,7 @@ typedef struct SJoinOperatorInfo {
SRspResultInfo
resultInfo
;
// todo refactor, add this info for each operator
}
SJoinOperatorInfo
;
static
void
doSetupSDataBlock
(
SSqlRes
*
pRes
,
SSDataBlock
*
pBlock
)
{
static
void
doSetupSDataBlock
(
SSqlRes
*
pRes
,
SSDataBlock
*
pBlock
,
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
)
{
int32_t
offset
=
0
;
char
*
pData
=
pRes
->
data
;
...
...
@@ -680,6 +681,18 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock) {
offset
+=
pColData
->
info
.
bytes
;
}
// filter data if needed
if
(
numOfFilterCols
>
0
)
{
doSetFilterColumnInfo
(
pFilterInfo
,
numOfFilterCols
,
pBlock
);
int8_t
*
p
=
calloc
(
pBlock
->
info
.
rows
,
sizeof
(
int8_t
));
bool
all
=
doFilterDataBlock
(
pFilterInfo
,
numOfFilterCols
,
pBlock
->
info
.
rows
,
p
);
if
(
!
all
)
{
doCompactSDataBlock
(
pBlock
,
pBlock
->
info
.
rows
,
p
);
}
tfree
(
p
);
}
// todo refactor: extract method
// set the timestamp range of current result data block
SColumnInfoData
*
pColData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
...
...
@@ -703,22 +716,11 @@ SSDataBlock* doGetDataBlock(void* param, bool* newgroup) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSDataBlock
*
pBlock
=
pInput
->
block
;
pOperator
->
pRuntimeEnv
->
current
=
pInput
->
pTableQueryInfo
;
pBlock
->
info
.
rows
=
pRes
->
numOfRows
;
if
(
pRes
->
numOfRows
!=
0
)
{
doSetupSDataBlock
(
pRes
,
pBlock
);
if
(
pInput
->
numOfFilterCols
>
0
)
{
doSetFilterColumnInfo
(
pInput
->
pFilterInfo
,
pInput
->
numOfFilterCols
,
pBlock
);
int8_t
*
p
=
calloc
(
pBlock
->
info
.
rows
,
sizeof
(
int8_t
));
bool
all
=
doFilterDataBlock
(
pInput
->
pFilterInfo
,
pInput
->
numOfFilterCols
,
pBlock
->
info
.
rows
,
p
);
if
(
!
all
)
{
doCompactSDataBlock
(
pBlock
,
pBlock
->
info
.
rows
,
p
);
}
tfree
(
p
);
}
doSetupSDataBlock
(
pRes
,
pBlock
,
pInput
->
pFilterInfo
,
pInput
->
numOfFilterCols
);
*
newgroup
=
false
;
return
pBlock
;
}
...
...
@@ -733,7 +735,7 @@ SSDataBlock* doGetDataBlock(void* param, bool* newgroup) {
}
pBlock
->
info
.
rows
=
pRes
->
numOfRows
;
doSetupSDataBlock
(
pRes
,
pBlock
);
doSetupSDataBlock
(
pRes
,
pBlock
,
pInput
->
pFilterInfo
,
pInput
->
numOfFilterCols
);
*
newgroup
=
false
;
return
pBlock
;
}
...
...
@@ -890,11 +892,14 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
SOperatorInfo
*
createDummyInputOperator
(
SSqlObj
*
pSql
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
)
{
assert
(
numOfCols
>
0
);
STimeWindow
win
=
{.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
};
SDummyInputInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SDummyInputInfo
));
pInfo
->
pSql
=
pSql
;
pInfo
->
pFilterInfo
=
pFilterInfo
;
pInfo
->
numOfFilterCols
=
numOfFilterCols
;
pInfo
->
pTableQueryInfo
=
createTmpTableQueryInfo
(
win
);
pInfo
->
block
=
calloc
(
numOfCols
,
sizeof
(
SSDataBlock
));
pInfo
->
block
->
info
.
numOfCols
=
numOfCols
;
...
...
@@ -980,12 +985,32 @@ void convertQueryResult(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
pRes
->
completed
=
(
pRes
->
numOfRows
==
0
);
}
static
void
createInputDataFilterInfo
(
SQueryInfo
*
px
,
int32_t
numOfCol1
,
int32_t
*
numOfFilterCols
,
SSingleColumnFilterInfo
**
pFilterInfo
)
{
SColumnInfo
*
tableCols
=
calloc
(
numOfCol1
,
sizeof
(
SColumnInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfCol1
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
px
->
colList
,
i
);
if
(
pCol
->
info
.
flist
.
numOfFilters
>
0
)
{
(
*
numOfFilterCols
)
+=
1
;
}
tableCols
[
i
]
=
pCol
->
info
;
}
if
((
*
numOfFilterCols
)
>
0
)
{
doCreateFilterInfo
(
tableCols
,
numOfCol1
,
(
*
numOfFilterCols
),
pFilterInfo
,
0
);
}
tfree
(
tableCols
);
}
void
handleDownstreamOperator
(
SSqlObj
**
pSqlObjList
,
int32_t
numOfUpstream
,
SQueryInfo
*
px
,
SSqlRes
*
pOutput
)
{
// handle the following query process
if
(
px
->
pQInfo
==
NULL
)
{
SColumnInfo
*
pColumnInfo
=
extractColumnInfoFromResult
(
px
->
colList
);
SSchema
*
pSchema
=
tscGetTableSchema
(
px
->
pTableMetaInfo
[
0
]
->
pTableMeta
);
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
px
,
0
)
->
pTableMeta
;
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
STableGroupInfo
tableGroupInfo
=
{
.
numOfTables
=
1
,
.
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
),
...
...
@@ -1001,23 +1026,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
taosArrayPush
(
tableGroupInfo
.
pGroupList
,
&
group
);
// if it is a join query, create join operator here
int32_t
numOfCol1
=
p
x
->
pTableMetaInfo
[
0
]
->
p
TableMeta
->
tableInfo
.
numOfColumns
;
int32_t
numOfCol1
=
pTableMeta
->
tableInfo
.
numOfColumns
;
int32_t
numOfFilterCols
=
0
;
SColumnInfo
*
tableCols
=
calloc
(
numOfCol1
,
sizeof
(
SColumnInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfCol1
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
px
->
colList
,
i
);
if
(
pCol
->
info
.
flist
.
numOfFilters
>
0
)
{
numOfFilterCols
+=
1
;
}
tableCols
[
i
]
=
pCol
->
info
;
}
SSingleColumnFilterInfo
*
pFilterInfo
=
NULL
;
if
(
numOfFilterCols
>
0
)
{
doCreateFilterInfo
(
tableCols
,
numOfCol1
,
numOfFilterCols
,
&
pFilterInfo
,
0
);
}
createInputDataFilterInfo
(
px
,
numOfCol1
,
&
numOfFilterCols
,
&
pFilterInfo
);
SOperatorInfo
*
pSourceOperator
=
createDummyInputOperator
(
pSqlObjList
[
0
],
pSchema
,
numOfCol1
,
pFilterInfo
,
numOfFilterCols
);
...
...
@@ -1033,24 +1046,14 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
int32_t
offset
=
pSourceOperator
->
numOfOutput
;
for
(
int32_t
i
=
1
;
i
<
px
->
numOfTables
;
++
i
)
{
SSchema
*
pSchema1
=
tscGetTableSchema
(
px
->
pTableMetaInfo
[
i
]
->
pTableMeta
);
int32_t
n
=
px
->
pTableMetaInfo
[
i
]
->
pTableMeta
->
tableInfo
.
numOfColumns
;
int32_t
numOfFilterCols1
=
0
;
SColumnInfo
*
tableCols1
=
calloc
(
numOfCol1
,
sizeof
(
SColumnInfo
));
for
(
int32_t
j
=
0
;
j
<
numOfCol1
;
++
j
)
{
SColumn
*
pCol
=
taosArrayGetP
(
px
->
colList
,
j
);
if
(
pCol
->
info
.
flist
.
numOfFilters
>
0
)
{
numOfFilterCols
+=
1
;
}
STableMeta
*
pTableMeta1
=
tscGetMetaInfo
(
px
,
i
)
->
pTableMeta
;
tableCols1
[
j
]
=
pCol
->
info
;
}
SSchema
*
pSchema1
=
tscGetTableSchema
(
pTableMeta1
)
;
int32_t
n
=
pTableMeta1
->
tableInfo
.
numOfColumns
;
int32_t
numOfFilterCols1
=
0
;
SSingleColumnFilterInfo
*
pFilterInfo1
=
NULL
;
if
(
numOfFilterCols1
>
0
)
{
doCreateFilterInfo
(
tableCols1
,
numOfCol1
,
numOfFilterCols1
,
&
pFilterInfo1
,
0
);
}
createInputDataFilterInfo
(
px
,
numOfCol1
,
&
numOfFilterCols1
,
&
pFilterInfo1
);
p
[
i
]
=
createDummyInputOperator
(
pSqlObjList
[
i
],
pSchema1
,
n
,
pFilterInfo1
,
numOfFilterCols1
);
memcpy
(
&
schema
[
offset
],
pSchema1
,
n
*
sizeof
(
SSchema
));
...
...
@@ -1068,6 +1071,9 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
px
->
pQInfo
=
createQInfoFromQueryNode
(
px
,
&
tableGroupInfo
,
pSourceOperator
,
NULL
,
NULL
,
MASTER_SCAN
);
tfree
(
pColumnInfo
);
tfree
(
schema
);
// set the pRuntimeEnv for pSourceOperator
pSourceOperator
->
pRuntimeEnv
=
&
px
->
pQInfo
->
runtimeEnv
;
}
uint64_t
qId
=
0
;
...
...
src/query/inc/qExecutor.h
浏览文件 @
ea0b5b9b
...
...
@@ -552,6 +552,8 @@ int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId);
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
);
STableQueryInfo
*
createTableQueryInfo
(
SQueryAttr
*
pQueryAttr
,
void
*
pTable
,
bool
groupbyColumn
,
STimeWindow
win
,
void
*
buf
);
STableQueryInfo
*
createTmpTableQueryInfo
(
STimeWindow
win
);
int32_t
buildArithmeticExprFromMsg
(
SExprInfo
*
pArithExprInfo
,
void
*
pQueryMsg
);
bool
isQueryKilled
(
SQInfo
*
pQInfo
);
...
...
src/query/src/qExecutor.c
浏览文件 @
ea0b5b9b
...
...
@@ -3237,6 +3237,25 @@ STableQueryInfo *createTableQueryInfo(SQueryAttr* pQueryAttr, void* pTable, bool
return
pTableQueryInfo
;
}
STableQueryInfo
*
createTmpTableQueryInfo
(
STimeWindow
win
)
{
STableQueryInfo
*
pTableQueryInfo
=
calloc
(
1
,
sizeof
(
STableQueryInfo
));
pTableQueryInfo
->
win
=
win
;
pTableQueryInfo
->
lastKey
=
win
.
skey
;
pTableQueryInfo
->
pTable
=
NULL
;
pTableQueryInfo
->
cur
.
vgroupIndex
=
-
1
;
// set more initial size of interval/groupby query
int32_t
initialSize
=
16
;
int32_t
code
=
initResultRowInfo
(
&
pTableQueryInfo
->
resInfo
,
initialSize
,
TSDB_DATA_TYPE_INT
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
return
pTableQueryInfo
;
}
void
destroyTableQueryInfoImpl
(
STableQueryInfo
*
pTableQueryInfo
)
{
if
(
pTableQueryInfo
==
NULL
)
{
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录