Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
51db5f57
T
TDengine
项目概览
Tonvia
/
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,发现更多精彩内容 >>
提交
51db5f57
编写于
2月 17, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor
上级
966ca160
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
239 addition
and
56 deletion
+239
-56
src/client/src/tscServer.c
src/client/src/tscServer.c
+12
-17
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+11
-4
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+1
-0
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+214
-34
src/query/src/queryMain.c
src/query/src/queryMain.c
+1
-1
未找到文件。
src/client/src/tscServer.c
浏览文件 @
51db5f57
...
...
@@ -856,33 +856,28 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
for
(
int32_t
i
=
0
;
i
<
output
;
++
i
)
{
SInternalField
*
pField
=
tscFieldInfoGetInternalField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
SSqlExpr
*
pExpr
=
pField
->
pSqlExpr
;
// this should be switched to projection query
if
(
pExpr
!=
NULL
)
{
if
(
!
tscValidateColumnId
(
pTableMetaInfo
,
pExpr
->
colInfo
.
colId
,
pExpr
->
numOfParams
))
{
tscError
(
"%p table schema is not matched with parsed sql"
,
pSql
);
return
TSDB_CODE_TSC_INVALID_SQL
;
}
pSqlFuncExpr1
->
colInfo
.
colId
=
htons
(
pExpr
->
colInfo
.
colId
);
pSqlFuncExpr1
->
colInfo
.
colIndex
=
htons
(
pExpr
->
colInfo
.
colIndex
);
pSqlFuncExpr1
->
colInfo
.
flag
=
htons
(
pExpr
->
colInfo
.
flag
);
pSqlFuncExpr1
->
functionId
=
htons
(
pExpr
->
functionId
);
pSqlFuncExpr1
->
numOfParams
=
htons
(
pExpr
->
numOfParams
);
pMsg
+=
sizeof
(
SSqlFuncMsg
);
pSqlFuncExpr1
->
numOfParams
=
0
;
// no params for projection query
pSqlFuncExpr1
->
functionId
=
htons
(
TSDB_FUNC_PRJ
);
pSqlFuncExpr1
->
colInfo
.
colId
=
htons
(
pExpr
->
resColId
);
pSqlFuncExpr1
->
colInfo
.
flag
=
htons
(
TSDB_COL_NORMAL
);
for
(
int32_t
j
=
0
;
j
<
pExpr
->
numOfParams
;
++
j
)
{
// todo add log
pSqlFuncExpr1
->
arg
[
j
].
argType
=
htons
((
uint16_t
)
pExpr
->
param
[
j
].
nType
);
pSqlFuncExpr1
->
arg
[
j
].
argBytes
=
htons
(
pExpr
->
param
[
j
].
nLen
);
if
(
pExpr
->
param
[
j
].
nType
==
TSDB_DATA_TYPE_BINARY
)
{
memcpy
(
pMsg
,
pExpr
->
param
[
j
].
pz
,
pExpr
->
param
[
j
].
nLen
);
pMsg
+=
pExpr
->
param
[
j
].
nLen
;
}
else
{
pSqlFuncExpr1
->
arg
[
j
].
argValue
.
i64
=
htobe64
(
pExpr
->
param
[
j
].
i64
);
for
(
int32_t
f
=
0
;
f
<
tscSqlExprNumOfExprs
(
pQueryInfo
);
++
f
)
{
SSqlExpr
*
pe
=
tscSqlExprGet
(
pQueryInfo
,
f
);
if
(
pe
==
pExpr
)
{
pSqlFuncExpr1
->
colInfo
.
colIndex
=
htons
(
f
);
break
;
}
}
pMsg
+=
sizeof
(
SSqlFuncMsg
);
pSqlFuncExpr1
=
(
SSqlFuncMsg
*
)
pMsg
;
}
else
{
assert
(
pField
->
pArithExprInfo
!=
NULL
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
51db5f57
...
...
@@ -283,12 +283,12 @@ typedef struct SQueryRuntimeEnv {
SArithmeticSupport
*
sasArray
;
SOperatorInfo
*
pi
;
SSDataBlock
*
outputBuf
;
SSDataBlock
*
outputBuf
;
int32_t
groupIndex
;
int32_t
tableIndex
;
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
SOperatorInfo
*
proot
;
SOperatorInfo
*
proot
;
SGroupResInfo
groupResInfo
;
}
SQueryRuntimeEnv
;
...
...
@@ -362,8 +362,6 @@ typedef struct STableScanInfo {
int64_t
elapsedTime
;
}
STableScanInfo
;
SOperatorInfo
optrList
[
5
];
typedef
struct
SAggOperatorInfo
{
SResultRowInfo
*
pResultRowInfo
;
STableQueryInfo
*
pTableQueryInfo
;
...
...
@@ -396,10 +394,19 @@ typedef struct SHashIntervalOperatorInfo {
SQLFunctionCtx
*
pCtx
;
}
SHashIntervalOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
SResultRowInfo
*
pResultRowInfo
;
STableQueryInfo
*
pTableQueryInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
;
}
SFillOperatorInfo
;
void
freeParam
(
SQueryParam
*
param
);
int32_t
convertQueryMsg
(
SQueryTableMsg
*
pQueryMsg
,
SQueryParam
*
param
);
int32_t
createQueryFuncExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
SSqlFuncMsg
**
pExprMsg
,
SColumnInfo
*
pTagCols
);
int32_t
createIndirectQueryFuncExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
SSqlFuncMsg
**
pExprMsg
,
SExprInfo
*
prevExpr
);
SSqlGroupbyExpr
*
createGroupbyExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
SColIndex
*
pColIndex
,
int32_t
*
code
);
SQInfo
*
createQInfoImpl
(
SQueryTableMsg
*
pQueryMsg
,
SSqlGroupbyExpr
*
pGroupbyExpr
,
SExprInfo
*
pExprs
,
SExprInfo
*
pSecExprs
,
STableGroupInfo
*
pTableGroupInfo
,
SColumnInfo
*
pTagCols
,
bool
stableQuery
,
char
*
sql
);
...
...
src/query/src/qAggMain.c
浏览文件 @
51db5f57
...
...
@@ -1925,6 +1925,7 @@ static void last_function(SQLFunctionCtx *pCtx) {
continue
;
}
}
memcpy
(
pCtx
->
pOutput
,
data
,
pCtx
->
inputBytes
);
TSKEY
ts
=
GET_TS_DATA
(
pCtx
,
i
);
...
...
src/query/src/qExecutor.c
浏览文件 @
51db5f57
...
...
@@ -1220,10 +1220,11 @@ static void doWindowBorderInterpolation(SQueryRuntimeEnv* pRuntimeEnv, SDataBloc
}
static
void
setInputSDataBlock
(
SOperatorInfo
*
pOperator
,
SQLFunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
)
{
static
void
setInputSDataBlock
(
SOperatorInfo
*
pOperator
,
SQLFunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
int32_t
order
)
{
if
(
pCtx
[
0
].
pInput
==
NULL
&&
pSDataBlock
->
pDataBlock
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
pCtx
[
i
].
size
=
pSDataBlock
->
info
.
rows
;
pCtx
[
i
].
order
=
order
;
SColIndex
*
pCol
=
&
pOperator
->
pExpr
[
i
].
base
.
colInfo
;
if
(
TSDB_COL_IS_NORMAL_COL
(
pCol
->
flag
))
{
...
...
@@ -1234,16 +1235,17 @@ static void setInputSDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, S
SQLFunctionCtx
*
pCtx1
=
&
pCtx
[
i
];
pCtx1
->
pInput
=
p
->
pData
;
uint32_t
status
=
aAggs
[
pCtx
->
functionId
].
status
;
uint32_t
status
=
aAggs
[
pCtx
1
->
functionId
].
status
;
if
((
status
&
(
TSDB_FUNCSTATE_SELECTIVITY
|
TSDB_FUNCSTATE_NEED_TS
))
!=
0
)
{
SColumnInfoData
*
tsInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
0
);
pCtx
->
ptsList
=
tsInfo
->
pData
;
pCtx
1
->
ptsList
=
tsInfo
->
pData
;
}
}
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
pCtx
[
i
].
size
=
pSDataBlock
->
info
.
rows
;
pCtx
[
i
].
order
=
order
;
}
}
}
...
...
@@ -6307,7 +6309,7 @@ static UNUSED_FUNC int32_t getTableScanId(STableScanInfo* pTableScanInfo) {
return
pTableScanInfo
->
current
;
}
static
UNUSED_FUNC
int32_t
getTableScanOrder
(
STableScanInfo
*
pTableScanInfo
)
{
static
int32_t
getTableScanOrder
(
STableScanInfo
*
pTableScanInfo
)
{
return
pTableScanInfo
->
order
;
}
...
...
@@ -6324,9 +6326,12 @@ static SSDataBlock* doAggregation(void* param) {
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQLFunctionCtx
*
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pOperator
->
numOfOutput
,
pOperator
->
pExpr
,
pQuery
->
order
.
order
,
pQuery
->
vgId
);
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
setDefaultOutputBuf
(
pRuntimeEnv
,
pCtx
,
pRuntimeEnv
->
outputBuf
);
SSDataBlock
*
pRes
=
createOutputBuf
(
pOperator
->
pExpr
,
pOperator
->
numOfOutput
);
setDefaultOutputBuf
(
pRuntimeEnv
,
pCtx
,
pRes
);
int32_t
order
=
pQuery
->
order
.
order
;
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
pQuery
->
pos
=
0
;
while
(
1
)
{
...
...
@@ -6335,8 +6340,13 @@ static SSDataBlock* doAggregation(void* param) {
break
;
}
if
(
strncasecmp
(
upstream
->
name
,
"BidirectionSeqScanTableOp"
,
strlen
(
"BidirectionSeqScanTableOp"
))
==
0
)
{
STableScanInfo
*
pScanInfo
=
upstream
->
optInfo
;
order
=
getTableScanOrder
(
pScanInfo
);
}
// the pDataBlock are always the same one, no need to call this again
setInputSDataBlock
(
pOperator
,
pCtx
,
pBlock
);
setInputSDataBlock
(
pOperator
,
pCtx
,
pBlock
,
order
);
aggApplyFunctions
(
pRuntimeEnv
,
pOperator
,
pCtx
,
pBlock
);
}
...
...
@@ -6344,10 +6354,10 @@ static SSDataBlock* doAggregation(void* param) {
setQueryStatus
(
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
finalizeQueryResult
(
pRuntimeEnv
);
pRuntimeEnv
->
outputBuf
->
info
.
rows
=
getNumOfResult
(
pRuntimeEnv
);
pRes
->
info
.
rows
=
getNumOfResult
(
pRuntimeEnv
);
destroySQLFunctionCtx
(
pCtx
,
pRes
->
info
.
numOfCols
);
destroySQLFunctionCtx
(
pCtx
,
pRuntimeEnv
->
outputBuf
->
info
.
numOfCols
);
return
pRuntimeEnv
->
outputBuf
;
return
pRes
;
}
static
SSDataBlock
*
doArithmeticOperation
(
void
*
param
)
{
...
...
@@ -6357,19 +6367,17 @@ static SSDataBlock* doArithmeticOperation(void* param) {
SQueryRuntimeEnv
*
pRuntimeEnv
=
pArithInfo
->
pRuntimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SSDataBlock
*
pRes
=
createOutputBuf
(
pOperator
->
pExpr
,
pOperator
->
numOfOutput
);
SSDataBlock
*
pRes
=
createOutputBuf
(
pOperator
->
pExpr
,
pOperator
->
numOfOutput
);
if
(
pArithInfo
->
pCtx
==
NULL
)
{
pArithInfo
->
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pOperator
->
numOfOutput
,
pOperator
->
pExpr
,
pQuery
->
order
.
order
,
pQuery
->
vgId
);
}
setDefaultOutputBuf
(
pRuntimeEnv
,
pArithInfo
->
pCtx
,
pRes
);
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
pRuntimeEnv
->
pQuery
->
pos
=
0
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
upstream
->
exec
(
upstream
);
SSDataBlock
*
pBlock
=
pOperator
->
upstream
->
exec
(
pOperator
->
upstream
);
if
(
pBlock
==
NULL
)
{
setQueryStatus
(
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
break
;
...
...
@@ -6387,6 +6395,8 @@ static SSDataBlock* doArithmeticOperation(void* param) {
SColumnInfoData
*
p
=
taosArrayGet
(
pBlock
->
pDataBlock
,
j
);
if
(
p
->
info
.
colId
==
pCol
->
colId
)
{
pArithInfo
->
pCtx
[
i
].
pInput
=
p
->
pData
;
pArithInfo
->
pCtx
[
i
].
inputType
=
p
->
info
.
type
;
pArithInfo
->
pCtx
[
i
].
inputBytes
=
p
->
info
.
bytes
;
break
;
}
}
...
...
@@ -6401,7 +6411,6 @@ static SSDataBlock* doArithmeticOperation(void* param) {
}
}
pRuntimeEnv
->
outputBuf
=
pRes
;
return
pRes
;
}
...
...
@@ -6413,8 +6422,7 @@ static SSDataBlock* doLimit(void* param) {
SLimitOperatorInfo
*
pInfo
=
pOperator
->
optInfo
;
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
SSDataBlock
*
pBlock
=
upstream
->
exec
(
upstream
);
SSDataBlock
*
pBlock
=
pOperator
->
upstream
->
exec
(
pOperator
->
upstream
);
if
(
pBlock
==
NULL
)
{
setQueryStatus
(
pInfo
->
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
pOperator
->
completed
=
true
;
...
...
@@ -6435,10 +6443,9 @@ static SSDataBlock* doOffset(void* param) {
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
SOffsetOperatorInfo
*
pInfo
=
pOperator
->
optInfo
;
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
upstream
->
exec
(
upstream
);
SSDataBlock
*
pBlock
=
pOperator
->
upstream
->
exec
(
pOperator
->
upstream
);
if
(
pBlock
==
NULL
)
{
setQueryStatus
(
pInfo
->
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
return
NULL
;
...
...
@@ -6471,14 +6478,17 @@ static SSDataBlock* doHashIntervalAgg(void* param) {
return
NULL
;
}
SAggOperatorInfo
*
pAggInfo
=
pOperator
->
optInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
pAggInfo
->
pRuntimeEnv
;
SHashIntervalOperatorInfo
*
pIntervalInfo
=
pOperator
->
optInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
pIntervalInfo
->
pRuntimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQLFunctionCtx
*
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pOperator
->
numOfOutput
,
pOperator
->
pExpr
,
pQuery
->
order
.
order
,
pQuery
->
vgId
);
S
OperatorInfo
*
upstream
=
pOperator
->
upstream
;
S
SDataBlock
*
pRes
=
createOutputBuf
(
pOperator
->
pExpr
,
pOperator
->
numOfOutput
)
;
int32_t
order
=
pQuery
->
order
.
order
;
SOperatorInfo
*
upstream
=
pOperator
->
upstream
;
pQuery
->
pos
=
0
;
while
(
1
)
{
...
...
@@ -6487,8 +6497,13 @@ static SSDataBlock* doHashIntervalAgg(void* param) {
break
;
}
if
(
strncasecmp
(
upstream
->
name
,
"BidirectionSeqScanTableOp"
,
strlen
(
"BidirectionSeqScanTableOp"
))
==
0
)
{
STableScanInfo
*
pScanInfo
=
upstream
->
optInfo
;
order
=
getTableScanOrder
(
pScanInfo
);
}
// the pDataBlock are always the same one, no need to call this again
setInputSDataBlock
(
pOperator
,
pCtx
,
pBlock
);
setInputSDataBlock
(
pOperator
,
pCtx
,
pBlock
,
order
);
hashIntervalAgg
(
pRuntimeEnv
,
pOperator
,
pCtx
,
pBlock
);
}
...
...
@@ -6501,10 +6516,47 @@ static SSDataBlock* doHashIntervalAgg(void* param) {
destroySQLFunctionCtx
(
pCtx
,
pOperator
->
numOfOutput
);
initGroupResInfo
(
&
pRuntimeEnv
->
groupResInfo
,
&
pRuntimeEnv
->
resultRowInfo
,
pQuery
->
limit
.
offset
);
toSSDataBlock
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pR
untimeEnv
->
outputBuf
);
toSSDataBlock
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pR
es
);
// pRuntimeEnv->outputBuf->info.rows = getNumOfResult(pRuntimeEnv);
return
pRuntimeEnv
->
outputBuf
;
return
pRes
;
}
static
SSDataBlock
*
doFill
(
void
*
param
)
{
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
if
(
pOperator
->
completed
)
{
return
NULL
;
}
SFillOperatorInfo
*
pInfo
=
pOperator
->
optInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
pInfo
->
pRuntimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
while
(
1
)
{
SSDataBlock
*
pBlock
=
pOperator
->
upstream
->
exec
(
pOperator
->
upstream
);
if
(
pBlock
==
NULL
)
{
setQueryStatus
(
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
memcpy
(
pQuery
->
sdata
[
i
]
->
data
,
pColInfoData
->
pData
,
pColInfoData
->
info
.
bytes
*
pBlock
->
info
.
rows
);
}
taosFillSetStartInfo
(
pRuntimeEnv
->
pFillInfo
,
pBlock
->
info
.
rows
,
pBlock
->
info
.
window
.
ekey
);
taosFillSetDataBlockFromFilePage
(
pRuntimeEnv
->
pFillInfo
,
(
const
tFilePage
**
)
pQuery
->
sdata
);
pQuery
->
rec
.
rows
=
doFillGapsInResults
(
pRuntimeEnv
,
(
tFilePage
**
)
pQuery
->
sdata
);
// here the pQuery->rec.rows == 0
if
(
!
hasRemainData
(
&
pRuntimeEnv
->
groupResInfo
)
&&
!
taosFillHasMoreResults
(
pRuntimeEnv
->
pFillInfo
))
{
break
;
}
return
NULL
;
}
return
NULL
;
}
// todo set the attribute of query scan count
...
...
@@ -6630,6 +6682,28 @@ static SOperatorInfo* createHashIntervalAggOperatorInfo(STableQueryInfo* pTableQ
return
pOperator
;
}
static
UNUSED_FUNC
SOperatorInfo
*
createFillOperatorInfo
(
STableQueryInfo
*
pTableQueryInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
inputOptr
)
{
SHashIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SHashIntervalOperatorInfo
));
pInfo
->
pRuntimeEnv
=
pRuntimeEnv
;
pInfo
->
pTableQueryInfo
=
pTableQueryInfo
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"FillOp"
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
completed
=
false
;
pOperator
->
upstream
=
inputOptr
;
pOperator
->
exec
=
doFill
;
pOperator
->
pExpr
=
pRuntimeEnv
->
pQuery
->
pExpr1
;
pOperator
->
numOfOutput
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
pOperator
->
optInfo
=
pInfo
;
return
pOperator
;
}
/*
* in each query, this function will be called only once, no retry for further result.
*
...
...
@@ -6644,8 +6718,8 @@ void tableAggregationProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
return
;
}
SSDataBlock
*
pResBlock
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
pR
esBlock
->
info
.
rows
;
pRuntimeEnv
->
outputBuf
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
pR
untimeEnv
->
outputBuf
->
info
.
rows
;
}
static
void
tableProjectionProcess
(
SQInfo
*
pQInfo
,
STableQueryInfo
*
pTableInfo
)
{
...
...
@@ -6664,8 +6738,8 @@ static void tableProjectionProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo)
// return;
// }
SSDataBlock
*
pResBlock
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
(
pR
esBlock
!=
NULL
)
?
pResBlock
->
info
.
rows
:
0
;
pRuntimeEnv
->
outputBuf
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
(
pR
untimeEnv
->
outputBuf
!=
NULL
)
?
pRuntimeEnv
->
outputBuf
->
info
.
rows
:
0
;
#if 0
while (1) {
...
...
@@ -6756,8 +6830,8 @@ static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
}
}
SSDataBlock
*
pResBlock
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
pR
esBlock
->
info
.
rows
;
pRuntimeEnv
->
outputBuf
=
pRuntimeEnv
->
proot
->
exec
(
pRuntimeEnv
->
proot
);
pQuery
->
rec
.
rows
=
pR
untimeEnv
->
outputBuf
->
info
.
rows
;
#if 0
// scanOneTableDataBlocks(pRuntimeEnv, newStartKey);
// finalizeQueryResult(pRuntimeEnv);
...
...
@@ -7469,6 +7543,114 @@ int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutpu
return
TSDB_CODE_SUCCESS
;
}
int32_t
createIndirectQueryFuncExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
int32_t
numOfOutput
,
SExprInfo
**
pExprInfo
,
SSqlFuncMsg
**
pExprMsg
,
SExprInfo
*
prevExpr
)
{
*
pExprInfo
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SExprInfo
*
pExprs
=
(
SExprInfo
*
)
calloc
(
numOfOutput
,
sizeof
(
SExprInfo
));
if
(
pExprs
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
bool
isSuperTable
=
QUERY_IS_STABLE_QUERY
(
pQueryMsg
->
queryType
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pExprs
[
i
].
base
=
*
pExprMsg
[
i
];
pExprs
[
i
].
bytes
=
0
;
int16_t
type
=
0
;
int16_t
bytes
=
0
;
// parse the arithmetic expression
if
(
pExprs
[
i
].
base
.
functionId
==
TSDB_FUNC_ARITHM
)
{
code
=
buildArithmeticExprFromMsg
(
&
pExprs
[
i
],
pQueryMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pExprs
);
return
code
;
}
type
=
TSDB_DATA_TYPE_DOUBLE
;
bytes
=
tDataTypes
[
type
].
bytes
;
// } else if (pExprs[i].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX && pExprs[i].base.functionId == TSDB_FUNC_TAGPRJ) { // parse the normal column
// SSchema* s = tGetTbnameColumnSchema();
// type = s->type;
// bytes = s->bytes;
// } else if (pExprs[i].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX) {
// SSchema s = tGetBlockDistColumnSchema();
// type = s.type;
// bytes = s.bytes;
// } else if (pExprs[i].base.colInfo.colId <= TSDB_UD_COLUMN_INDEX) {
// // it is a user-defined constant value column
// assert(pExprs[i].base.functionId == TSDB_FUNC_PRJ);
//
// type = pExprs[i].base.arg[1].argType;
// bytes = pExprs[i].base.arg[1].argBytes;
//
// if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
// bytes += VARSTR_HEADER_SIZE;
// }
}
else
{
int32_t
index
=
pExprs
[
i
].
base
.
colInfo
.
colIndex
;
assert
(
prevExpr
[
index
].
base
.
resColId
==
pExprs
[
i
].
base
.
colInfo
.
colId
);
// int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
// if (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag)) {
// if (j < TSDB_BLOCK_DIST_COLUMN_INDEX || j >= pQueryMsg->numOfTags) {
// return TSDB_CODE_QRY_INVALID_MSG;
// }
// } else {
// if (j < PRIMARYKEY_TIMESTAMP_COL_INDEX || j >= pQueryMsg->numOfCols) {
// return TSDB_CODE_QRY_INVALID_MSG;
// }
// }
//
// if (pExprs[i].base.colInfo.colId != TSDB_TBNAME_COLUMN_INDEX && j >= 0) {
// SColumnInfo* pCol = (TSDB_COL_IS_TAG(pExprs[i].base.colInfo.flag))? &pTagCols[j]:&pQueryMsg->colList[j];
// type = pCol->type;
// bytes = pCol->bytes;
// } else {
// SSchema* s = tGetTbnameColumnSchema();
type
=
prevExpr
[
index
].
type
;
bytes
=
prevExpr
[
index
].
bytes
;
// }
}
int32_t
param
=
(
int32_t
)
pExprs
[
i
].
base
.
arg
[
0
].
argValue
.
i64
;
if
(
getResultDataInfo
(
type
,
bytes
,
pExprs
[
i
].
base
.
functionId
,
param
,
&
pExprs
[
i
].
type
,
&
pExprs
[
i
].
bytes
,
&
pExprs
[
i
].
interBytes
,
0
,
isSuperTable
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pExprs
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
assert
(
isValidDataType
(
pExprs
[
i
].
type
));
}
// // TODO refactor
// for (int32_t i = 0; i < numOfOutput; ++i) {
// pExprs[i].base = *pExprMsg[i];
// int16_t functId = pExprs[i].base.functionId;
//
// if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
// int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
// if (j < 0 || j >= pQueryMsg->numOfCols) {
// return TSDB_CODE_QRY_INVALID_MSG;
// } else {
// SColumnInfo *pCol = &pQueryMsg->colList[j];
// int32_t ret =
// getResultDataInfo(pCol->type, pCol->bytes, functId, (int32_t)pExprs[i].base.arg[0].argValue.i64,
// &pExprs[i].type, &pExprs[i].bytes, &pExprs[i].interBytes, tagLen, isSuperTable);
// assert(ret == TSDB_CODE_SUCCESS);
// }
// }
// }
*
pExprInfo
=
pExprs
;
return
TSDB_CODE_SUCCESS
;
}
SSqlGroupbyExpr
*
createGroupbyExprFromMsg
(
SQueryTableMsg
*
pQueryMsg
,
SColIndex
*
pColIndex
,
int32_t
*
code
)
{
if
(
pQueryMsg
->
numOfGroupCols
==
0
)
{
return
NULL
;
...
...
@@ -7667,8 +7849,6 @@ SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr
}
doUpdateExprColumnIndex
(
pQuery
);
pQInfo
->
runtimeEnv
.
outputBuf
=
createOutputBuf
(
pQuery
->
pExpr1
,
pQuery
->
numOfOutput
);
int32_t
ret
=
createFilterInfo
(
pQInfo
,
pQuery
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_cleanup
;
...
...
src/query/src/queryMain.c
浏览文件 @
51db5f57
...
...
@@ -96,7 +96,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
}
if
(
param
.
pSecExprMsg
!=
NULL
)
{
if
((
code
=
create
QueryFuncExprFromMsg
(
pQueryMsg
,
pQueryMsg
->
secondStageOutput
,
&
param
.
pSecExprs
,
param
.
pSecExprMsg
,
param
.
pTagColumnInfo
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
create
IndirectQueryFuncExprFromMsg
(
pQueryMsg
,
pQueryMsg
->
secondStageOutput
,
&
param
.
pSecExprs
,
param
.
pSecExprMsg
,
param
.
pExprs
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_over
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录