Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1a1cd551
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1a1cd551
编写于
1月 20, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] refactor.
上级
f04292b8
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
818 addition
and
602 deletion
+818
-602
include/libs/function/function.h
include/libs/function/function.h
+7
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+4
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+574
-542
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+4
-0
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+8
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+4
-5
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+176
-14
source/libs/function/inc/taggfunction.h
source/libs/function/inc/taggfunction.h
+0
-7
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+2
-1
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+14
-13
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+5
-0
source/libs/planner/src/logicPlan.c
source/libs/planner/src/logicPlan.c
+12
-10
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+2
-2
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+3
-3
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
未找到文件。
include/libs/function/function.h
浏览文件 @
1a1cd551
...
...
@@ -80,6 +80,13 @@ extern "C" {
#define FUNCTION_COV 38
typedef
struct
SResultRowEntryInfo
{
int8_t
hasResult
;
// result generated, not NULL value
bool
initialized
;
// output buffer has been initialized
bool
complete
;
// query has completed
uint32_t
numOfRes
;
// num of output result in current buffer
}
SResultRowEntryInfo
;
// determine the real data need to calculated the result
enum
{
BLK_DATA_NO_NEEDED
=
0x0
,
...
...
source/client/src/clientImpl.c
浏览文件 @
1a1cd551
...
...
@@ -259,7 +259,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag) {
SArray
*
execNode
=
taosArrayInit
(
4
,
sizeof
(
SQueryNodeAddr
));
SQueryNodeAddr
addr
=
{.
numOfEps
=
1
,
.
inUse
=
0
,
.
nodeId
=
2
};
addr
.
epAddr
[
0
].
port
=
603
0
;
addr
.
epAddr
[
0
].
port
=
710
0
;
strcpy
(
addr
.
epAddr
[
0
].
fqdn
,
"localhost"
);
taosArrayPush
(
execNode
,
&
addr
);
...
...
@@ -728,6 +728,7 @@ void* doFetchRow(SRequestObj* pRequest) {
goto
_return
;
}
else
if
(
pRequest
->
type
==
TDMT_MND_SHOW
)
{
pRequest
->
type
=
TDMT_MND_SHOW_RETRIEVE
;
epSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
);
}
else
if
(
pRequest
->
type
==
TDMT_VND_SHOW_TABLES
)
{
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
SShowReqInfo
*
pShowReqInfo
=
&
pRequest
->
body
.
showInfo
;
...
...
@@ -772,6 +773,8 @@ void* doFetchRow(SRequestObj* pRequest) {
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
pRequest
->
type
=
TDMT_VND_SHOW_TABLES_FETCH
;
}
else
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
&&
pResultInfo
->
pData
!=
NULL
)
{
return
NULL
;
}
SMsgSendInfo
*
body
=
buildMsgInfoImpl
(
pRequest
);
...
...
source/client/test/clientTests.cpp
浏览文件 @
1a1cd551
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
1a1cd551
...
...
@@ -230,7 +230,7 @@ typedef struct {
char
acct
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
uid
;
u
int64_t
uid
;
int32_t
cfgVersion
;
int32_t
vgVersion
;
int8_t
hashMethod
;
// default is 1
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
1a1cd551
...
...
@@ -855,6 +855,10 @@ static int32_t mndRetrieveStb(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
strncmp
(
pStb
->
db
,
pDb
->
name
,
tListLen
(
pStb
->
db
))
==
0
)
{
mError
(
"Inconsistent table data, name:%s, db:%s, dbUid:%"
PRIu64
,
pStb
->
name
,
pDb
->
name
,
pDb
->
uid
);
}
sdbRelease
(
pSdb
,
pStb
);
continue
;
}
...
...
source/libs/executor/inc/executil.h
浏览文件 @
1a1cd551
...
...
@@ -94,7 +94,7 @@ struct SUdfInfo;
int32_t
getOutputInterResultBufSize
(
struct
STaskAttr
*
pQueryAttr
);
size_t
getResultRowSize
(
struct
STaskRuntimeEnv
*
pRuntimeEnv
);
size_t
getResultRowSize
(
SArray
*
pExprInfo
);
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
,
int16_t
type
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
1a1cd551
...
...
@@ -419,6 +419,7 @@ typedef struct SOptrBasicInfo {
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
SQLFunctionCtx
*
pCtx
;
SSDataBlock
*
pRes
;
void
*
keyBuf
;
}
SOptrBasicInfo
;
typedef
struct
SOptrBasicInfo
STableIntervalOperatorInfo
;
...
...
@@ -426,6 +427,12 @@ typedef struct SOptrBasicInfo STableIntervalOperatorInfo;
typedef
struct
SAggOperatorInfo
{
SOptrBasicInfo
binfo
;
uint32_t
seed
;
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
char
*
keyBuf
;
// window key buffer
SResultRowPool
*
pool
;
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
}
SAggOperatorInfo
;
typedef
struct
SProjectOperatorInfo
{
...
...
@@ -554,7 +561,7 @@ SOperatorInfo* createDataBlocksOptScanInfo(void* pTsdbReadHandle, int32_t order,
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
S
Array
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
1a1cd551
...
...
@@ -168,16 +168,15 @@ void clearResultRow(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16_
}
// TODO refactor: use macro
struct
SResultRowEntryInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
index
,
int32_t
*
offset
)
{
SResultRowEntryInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
index
,
int32_t
*
offset
)
{
assert
(
index
>=
0
&&
offset
!=
NULL
);
// return (SResultRowEntryInfo*)((char*) pRow->pCellInfo + offset[index]);
return
NULL
;
}
size_t
getResultRowSize
(
STaskRuntimeEnv
*
pRuntimeEnv
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
return
0
;
// return (pQueryAttr->numOfOutput * sizeof(SResultRowEntryInfo)) + pQueryAttr->interBufSize + sizeof(SResultRow);
size_t
getResultRowSize
(
SArray
*
pExprInfo
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
return
(
numOfOutput
*
sizeof
(
SResultRowEntryInfo
))
+
/*pQueryAttr->interBufSize +*/
sizeof
(
SResultRow
);
}
SResultRowPool
*
initResultRowPool
(
size_t
size
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
1a1cd551
...
...
@@ -309,6 +309,31 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
return
res
;
}
SSDataBlock
*
createOutputBuf_rv
(
SArray
*
pExprInfo
,
int32_t
numOfRows
)
{
const
static
int32_t
minSize
=
8
;
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
SSDataBlock
*
res
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
res
->
info
.
numOfCols
=
numOfOutput
;
res
->
pDataBlock
=
taosArrayInit
(
numOfOutput
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SColumnInfoData
idata
=
{{
0
}};
SExprInfo
*
pExpr
=
taosArrayGet
(
pExprInfo
,
i
);
idata
.
info
.
type
=
pExpr
->
base
.
resSchema
.
type
;
idata
.
info
.
bytes
=
pExpr
->
base
.
resSchema
.
bytes
;
idata
.
info
.
colId
=
pExpr
->
base
.
resSchema
.
colId
;
int32_t
size
=
MAX
(
idata
.
info
.
bytes
*
numOfRows
,
minSize
);
idata
.
pData
=
calloc
(
1
,
size
);
// at least to hold a pointer on x64 platform
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
}
return
res
;
}
void
*
destroyOutputBuf
(
SSDataBlock
*
pBlock
)
{
if
(
pBlock
==
NULL
)
{
return
NULL
;
...
...
@@ -369,7 +394,7 @@ static bool hasNull(SColIndex* pColIndex, SColumnDataAgg *pStatis) {
return
true
;
}
static
void
prepareResultListBuffer
(
SResultRowInfo
*
pResultRowInfo
,
STaskRuntimeEnv
*
pRuntimeE
nv
)
{
static
void
prepareResultListBuffer
(
SResultRowInfo
*
pResultRowInfo
,
jmp_buf
e
nv
)
{
// more than the capacity, reallocate the resources
if
(
pResultRowInfo
->
size
<
pResultRowInfo
->
capacity
)
{
return
;
...
...
@@ -384,7 +409,7 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, STaskRuntime
char
*
t
=
realloc
(
pResultRowInfo
->
pResult
,
(
size_t
)(
newCapacity
*
POINTER_BYTES
));
if
(
t
==
NULL
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
longjmp
(
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
pResultRowInfo
->
pResult
=
(
SResultRow
**
)
t
;
...
...
@@ -473,7 +498,7 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR
}
if
(
!
existed
)
{
prepareResultListBuffer
(
pResultRowInfo
,
pRuntimeEnv
);
//
prepareResultListBuffer(pResultRowInfo, pRuntimeEnv);
SResultRow
*
pResult
=
NULL
;
if
(
p1
==
NULL
)
{
...
...
@@ -507,6 +532,80 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR
return
pResultRowInfo
->
pResult
[
pResultRowInfo
->
curPos
];
}
static
SResultRow
*
doSetResultOutBufByKey_rv
(
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
tableGroupId
,
SExecTaskInfo
*
pTaskInfo
,
bool
isIntervalQuery
,
SAggOperatorInfo
*
pAggInfo
)
{
bool
existed
=
false
;
SET_RES_WINDOW_KEY
(
pAggInfo
->
keyBuf
,
pData
,
bytes
,
tableGroupId
);
SResultRow
**
p1
=
(
SResultRow
**
)
taosHashGet
(
pAggInfo
->
pResultRowHashTable
,
pAggInfo
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
// in case of repeat scan/reverse scan, no new time window added.
if
(
isIntervalQuery
)
{
if
(
!
masterscan
)
{
// the *p1 may be NULL in case of sliding+offset exists.
return
(
p1
!=
NULL
)
?
*
p1
:
NULL
;
}
if
(
p1
!=
NULL
)
{
if
(
pResultRowInfo
->
size
==
0
)
{
existed
=
false
;
assert
(
pResultRowInfo
->
curPos
==
-
1
);
}
else
if
(
pResultRowInfo
->
size
==
1
)
{
existed
=
(
pResultRowInfo
->
pResult
[
0
]
==
(
*
p1
));
pResultRowInfo
->
curPos
=
0
;
}
else
{
// check if current pResultRowInfo contains the existed pResultRow
SET_RES_EXT_WINDOW_KEY
(
pAggInfo
->
keyBuf
,
pData
,
bytes
,
tid
,
pResultRowInfo
);
int64_t
*
index
=
taosHashGet
(
pAggInfo
->
pResultRowListSet
,
pAggInfo
->
keyBuf
,
GET_RES_EXT_WINDOW_KEY_LEN
(
bytes
));
if
(
index
!=
NULL
)
{
pResultRowInfo
->
curPos
=
(
int32_t
)
*
index
;
existed
=
true
;
}
else
{
existed
=
false
;
}
}
}
}
else
{
// In case of group by column query, the required SResultRow object must be existed in the pResultRowInfo object.
if
(
p1
!=
NULL
)
{
return
*
p1
;
}
}
if
(
!
existed
)
{
prepareResultListBuffer
(
pResultRowInfo
,
pTaskInfo
->
env
);
SResultRow
*
pResult
=
NULL
;
if
(
p1
==
NULL
)
{
pResult
=
getNewResultRow
(
pAggInfo
->
pool
);
int32_t
ret
=
initResultRow
(
pResult
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
// add a new result set for a new group
taosHashPut
(
pAggInfo
->
pResultRowHashTable
,
pAggInfo
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
pResult
,
POINTER_BYTES
);
SResultRowCell
cell
=
{.
groupId
=
tableGroupId
,
.
pRow
=
pResult
};
taosArrayPush
(
pAggInfo
->
pResultRowArrayList
,
&
cell
);
}
else
{
pResult
=
*
p1
;
}
pResultRowInfo
->
curPos
=
pResultRowInfo
->
size
;
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
++
]
=
pResult
;
int64_t
index
=
pResultRowInfo
->
curPos
;
SET_RES_EXT_WINDOW_KEY
(
pAggInfo
->
keyBuf
,
pData
,
bytes
,
tid
,
pResultRowInfo
);
taosHashPut
(
pAggInfo
->
pResultRowListSet
,
pAggInfo
->
keyBuf
,
GET_RES_EXT_WINDOW_KEY_LEN
(
bytes
),
&
index
,
POINTER_BYTES
);
}
// too many time window in query
if
(
pResultRowInfo
->
size
>
MAX_INTERVAL_TIME_WINDOW
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW
);
}
return
pResultRowInfo
->
pResult
[
pResultRowInfo
->
curPos
];
}
static
void
getInitialStartTimeWindow
(
STaskAttr
*
pQueryAttr
,
TSKEY
ts
,
STimeWindow
*
w
)
{
if
(
QUERY_IS_ASC_QUERY
(
pQueryAttr
))
{
getAlignQueryTimeWindow
(
pQueryAttr
,
ts
,
ts
,
pQueryAttr
->
window
.
ekey
,
w
);
...
...
@@ -1918,7 +2017,9 @@ static SQLFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
return
pFuncCtx
;
}
static
SQLFunctionCtx
*
createSqlFunctionCtx_rv
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
)
{
static
SQLFunctionCtx
*
createSqlFunctionCtx_rv
(
SArray
*
pExprInfo
,
int32_t
**
rowCellInfoOffset
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
SQLFunctionCtx
*
pFuncCtx
=
(
SQLFunctionCtx
*
)
calloc
(
numOfOutput
,
sizeof
(
SQLFunctionCtx
));
if
(
pFuncCtx
==
NULL
)
{
return
NULL
;
...
...
@@ -1931,7 +2032,9 @@ static SQLFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExpr, int32_t numOfOu
}
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SSqlExpr
*
pSqlExpr
=
&
pExpr
[
i
].
base
;
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
SSqlExpr
*
pSqlExpr
=
&
pExpr
->
base
;
SQLFunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
#if 0
SColIndex *pIndex = &pSqlExpr->colInfo;
...
...
@@ -2044,7 +2147,7 @@ static int32_t setupQueryRuntimeEnv(STaskRuntimeEnv *pRuntimeEnv, int32_t numOfT
pRuntimeEnv
->
pResultRowHashTable
=
taosHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pRuntimeEnv
->
pResultRowListSet
=
taosHashInit
(
numOfTables
*
10
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
pRuntimeEnv
->
keyBuf
=
malloc
(
pQueryAttr
->
maxTableColumnWidth
+
sizeof
(
int64_t
)
+
POINTER_BYTES
);
pRuntimeEnv
->
pool
=
initResultRowPool
(
getResultRowSize
(
pRuntimeEnv
));
//
pRuntimeEnv->pool = initResultRowPool(getResultRowSize(pRuntimeEnv));
pRuntimeEnv
->
pResultRowArrayList
=
taosArrayInit
(
numOfTables
,
sizeof
(
SResultRowCell
));
pRuntimeEnv
->
prevRow
=
malloc
(
POINTER_BYTES
*
pQueryAttr
->
numOfCols
+
pQueryAttr
->
srcRowSize
);
...
...
@@ -3457,6 +3560,43 @@ void setDefaultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, in
initCtxOutputBuffer
(
pCtx
,
pDataBlock
->
info
.
numOfCols
);
}
void
setDefaultOutputBuf_rv
(
SAggOperatorInfo
*
pAggInfo
,
int64_t
uid
,
int32_t
stage
,
SExecTaskInfo
*
pTaskInfo
)
{
SOptrBasicInfo
*
pInfo
=
&
pAggInfo
->
binfo
;
SQLFunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
int64_t
tid
=
0
;
pInfo
->
keyBuf
=
realloc
(
pInfo
->
keyBuf
,
sizeof
(
tid
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
);
SResultRow
*
pRow
=
doSetResultOutBufByKey_rv
(
pResultRowInfo
,
tid
,
(
char
*
)
&
tid
,
sizeof
(
tid
),
true
,
uid
,
pTaskInfo
,
false
,
pAggInfo
);
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
/*
* set the output buffer information and intermediate buffer
* not all queries require the interResultBuf, such as COUNT/TAGPRJ/PRJ/TAG etc.
*/
struct
SResultRowEntryInfo
*
pEntry
=
getResultCell
(
pRow
,
i
,
rowCellInfoOffset
);
cleanupResultRowEntry
(
pEntry
);
pCtx
[
i
].
resultInfo
=
pEntry
;
pCtx
[
i
].
pOutput
=
pData
->
pData
;
pCtx
[
i
].
currentStage
=
stage
;
assert
(
pCtx
[
i
].
pOutput
!=
NULL
);
// set the timestamp output buffer for top/bottom/diff query
int32_t
fid
=
pCtx
[
i
].
functionId
;
if
(
fid
==
FUNCTION_TOP
||
fid
==
FUNCTION_BOTTOM
||
fid
==
FUNCTION_DIFF
||
fid
==
FUNCTION_DERIVATIVE
)
{
if
(
i
>
0
)
pCtx
[
i
].
ptsOutputBuf
=
pCtx
[
i
-
1
].
pOutput
;
}
}
initCtxOutputBuffer
(
pCtx
,
pDataBlock
->
info
.
numOfCols
);
}
void
updateOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
,
int32_t
numOfInputRows
)
{
SSDataBlock
*
pDataBlock
=
pBInfo
->
pRes
;
...
...
@@ -6516,19 +6656,31 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
tfree
(
pOperator
);
}
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
S
Array
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SAggOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SAggOperatorInfo
));
// STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
int32_t
numOfRows
=
1
;
//(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery));
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
numOfRows
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx_rv
(
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
pInfo
->
binfo
.
pRes
=
createOutputBuf_rv
(
pExprInfo
,
numOfRows
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx_rv
(
pExprInfo
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
pResultRowHashTable
=
taosHashInit
(
10
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pInfo
->
pResultRowListSet
=
taosHashInit
(
100
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
pInfo
->
keyBuf
=
NULL
;
//malloc(pQueryAttr->maxTableColumnWidth + sizeof(int64_t) + POINTER_BYTES);
pInfo
->
pool
=
initResultRowPool
(
getResultRowSize
(
pExprInfo
));
pInfo
->
pResultRowArrayList
=
taosArrayInit
(
10
,
sizeof
(
SResultRowCell
));
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
pInfo
->
seed
=
rand
();
// setDefaultOutputBuf(pRuntimeEnv, &pInfo->binfo, pInfo->seed, MAIN_SCAN);
setDefaultOutputBuf_rv
(
pInfo
,
pInfo
->
seed
,
MAIN_SCAN
,
pTaskInfo
);
SExprInfo
*
p
=
calloc
(
numOfOutput
,
sizeof
(
SExprInfo
));
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pExprInfo
);
++
i
)
{
SExprInfo
*
pExpr
=
taosArrayGet
(
pExprInfo
,
i
);
memcpy
(
&
p
[
i
],
pExpr
,
sizeof
(
SExprInfo
));
}
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"TableAggregate"
;
...
...
@@ -6536,10 +6688,11 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
p
Expr
;
pOperator
->
pExpr
=
p
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pRuntimeEnv
=
NULL
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
exec
=
doAggregate
;
pOperator
->
cleanup
=
destroyAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
...
...
@@ -7485,8 +7638,17 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
}
else
if
(
pPhyNode
->
info
.
type
==
OP_Exchange
)
{
SExchangePhyNode
*
pEx
=
(
SExchangePhyNode
*
)
pPhyNode
;
return
createExchangeOperatorInfo
(
pEx
->
pSrcEndPoints
,
pEx
->
node
.
pTargets
,
pTaskInfo
);
}
else
{
assert
(
0
);
}
}
if
(
pPhyNode
->
info
.
type
==
OP_Aggregate
)
{
size_t
size
=
taosArrayGetSize
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhyNode
*
pChildNode
=
taosArrayGet
(
pPhyNode
->
pChildren
,
i
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
param
);
return
createAggregateOperatorInfo
(
op
,
pPhyNode
->
pTargets
,
pTaskInfo
);
}
}
}
...
...
source/libs/function/inc/taggfunction.h
浏览文件 @
1a1cd551
...
...
@@ -30,13 +30,6 @@ extern "C" {
extern
SAggFunctionInfo
aggFunc
[
35
];
typedef
struct
SResultRowEntryInfo
{
int8_t
hasResult
;
// result generated, not NULL value
bool
initialized
;
// output buffer has been initialized
bool
complete
;
// query has completed
uint32_t
numOfRes
;
// num of output result in current buffer
}
SResultRowEntryInfo
;
#define FUNCSTATE_SO 0x0u
#define FUNCSTATE_MO 0x1u // dynamic number of output, not multinumber of output e.g., TOP/BOTTOM
#define FUNCSTATE_STREAM 0x2u // function avail for stream
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
1a1cd551
...
...
@@ -2080,7 +2080,7 @@ static int32_t setColumnIndex(SQueryStmtInfo* pQueryInfo, SArray* pParamList, SC
STableMeta
*
pTableMeta
=
getMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
if
(
pParamList
==
NULL
)
{
// count(*) is equalled to count(primary_timestamp_key)
*
index
=
(
SColumnIndex
)
{
0
,
PRIMARYKEY_TIMESTAMP_COL_ID
,
false
};
*
index
=
(
SColumnIndex
)
{
0
,
0
,
false
};
*
columnSchema
=
*
(
SSchema
*
)
getOneColumnSchema
(
pTableMeta
,
index
->
columnIndex
);
}
else
{
tSqlExprItem
*
pParamElem
=
taosArrayGet
(
pParamList
,
0
);
...
...
@@ -3955,6 +3955,7 @@ int32_t qParserValidateSqlNode(SParseContext *pCtx, SSqlInfo* pInfo, SQueryStmtI
pQueryInfo
->
pTableMetaInfo
[
0
]
->
name
=
*
name
;
pQueryInfo
->
numOfTables
=
1
;
pQueryInfo
->
pTableMetaInfo
[
0
]
->
tagColList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
strcpy
(
pQueryInfo
->
pTableMetaInfo
[
0
]
->
aliasName
,
name
->
tname
);
code
=
setTableVgroupList
(
pCtx
,
name
,
&
pQueryInfo
->
pTableMetaInfo
[
0
]
->
vgroupList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
1a1cd551
...
...
@@ -26,18 +26,26 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
const
char
*
msg4
=
"pattern is invalid"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
const
char
*
msg7
=
"db is not specified"
;
/*
* database prefix in pInfo->pMiscInfo->a[0]
* wildcard in like clause in pInfo->pMiscInfo->a[1]
*/
int16_t
showType
=
pShowInfo
->
showType
;
if
(
showType
==
TSDB_MGMT_TABLE_TABLE
)
{
SVShowTablesReq
*
pShowReq
=
calloc
(
1
,
sizeof
(
SVShowTablesReq
));
SArray
*
array
=
NULL
;
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCtx
->
acctId
,
pCtx
->
db
,
strlen
(
pCtx
->
db
));
if
(
pCtx
->
db
==
NULL
&&
pShowInfo
->
prefix
.
n
==
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg7
);
}
SVShowTablesReq
*
pShowReq
=
calloc
(
1
,
sizeof
(
SVShowTablesReq
));
if
(
pShowInfo
->
prefix
.
n
>
0
)
{
tNameSetDbName
(
&
name
,
pCtx
->
acctId
,
pShowInfo
->
prefix
.
z
,
pShowInfo
->
prefix
.
n
);
}
else
{
tNameSetDbName
(
&
name
,
pCtx
->
acctId
,
pCtx
->
db
,
strlen
(
pCtx
->
db
));
}
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
...
...
@@ -715,6 +723,8 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
SMsgBuf
m
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
*
pMsgBuf
=
&
m
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
switch
(
pInfo
->
type
)
{
case
TSDB_SQL_CREATE_USER
:
case
TSDB_SQL_ALTER_USER
:
{
...
...
@@ -768,7 +778,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
pDcl
->
pMsg
=
(
char
*
)
buildUserManipulationMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
msgType
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_USER
)
?
TDMT_MND_CREATE_USER
:
TDMT_MND_ALTER_USER
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -810,7 +819,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
pDcl
->
pMsg
=
(
char
*
)
buildAcctManipulationMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
msgType
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_ACCT
)
?
TDMT_MND_CREATE_ACCT
:
TDMT_MND_ALTER_ACCT
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -818,7 +826,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
case
TSDB_SQL_DROP_USER
:
{
pDcl
->
pMsg
=
(
char
*
)
buildDropUserMsg
(
pInfo
,
&
pDcl
->
msgLen
,
pCtx
->
requestId
,
msgBuf
,
msgBufLen
);
pDcl
->
msgType
=
(
pInfo
->
type
==
TSDB_SQL_DROP_ACCT
)
?
TDMT_MND_DROP_ACCT
:
TDMT_MND_DROP_USER
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -855,7 +862,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
pDcl
->
pMsg
=
(
char
*
)
pUseDbMsg
;
pDcl
->
msgLen
=
sizeof
(
SUseDbReq
);
pDcl
->
msgType
=
TDMT_MND_USE_DB
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -884,7 +890,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
goto
_error
;
}
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
pDcl
->
pMsg
=
(
char
*
)
pCreateMsg
;
pDcl
->
msgLen
=
sizeof
(
SCreateDbReq
);
pDcl
->
msgType
=
(
pInfo
->
type
==
TSDB_SQL_CREATE_DB
)
?
TDMT_MND_CREATE_DB
:
TDMT_MND_ALTER_DB
;
...
...
@@ -913,7 +918,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
pDcl
->
msgType
=
TDMT_MND_DROP_DB
;
pDcl
->
msgLen
=
sizeof
(
SDropDbReq
);
pDcl
->
pMsg
=
(
char
*
)
pDropDbMsg
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -926,7 +930,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
pDcl
->
pMsg
=
(
char
*
)
buildCreateStbMsg
(
pCreateTable
,
&
pDcl
->
msgLen
,
pCtx
,
pMsgBuf
);
pDcl
->
msgType
=
TDMT_MND_CREATE_STB
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -947,7 +950,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
}
pDcl
->
msgType
=
TDMT_MND_CREATE_DNODE
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
@@ -958,7 +960,6 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseContext* pCtx, ch
}
pDcl
->
msgType
=
TDMT_MND_DROP_DNODE
;
pDcl
->
epSet
=
pCtx
->
mgmtEpSet
;
break
;
}
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
1a1cd551
...
...
@@ -1947,6 +1947,7 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param) {
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParseContext
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"name too long"
;
const
char
*
msg2
=
"invalid database name"
;
const
char
*
msg3
=
"db is not specified"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
char
*
p
=
strnchr
(
pTableName
->
z
,
TS_PATH_DELIMITER
[
0
],
pTableName
->
n
,
true
);
...
...
@@ -1984,6 +1985,10 @@ int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pParseCtx,
strncpy
(
name
,
pTableName
->
z
,
pTableName
->
n
);
strdequote
(
name
);
if
(
pParseCtx
->
db
==
NULL
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg3
);
}
code
=
tNameSetDbName
(
pName
,
pParseCtx
->
acctId
,
pParseCtx
->
db
,
strlen
(
pParseCtx
->
db
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
code
=
buildInvalidOperationMsg
(
pMsgBuf
,
msg2
);
...
...
source/libs/planner/src/logicPlan.c
浏览文件 @
1a1cd551
...
...
@@ -197,23 +197,25 @@ static SQueryPlanNode* doAddTableColumnNode(const SQueryStmtInfo* pQueryInfo, SQ
SQueryPlanNode
*
pNode
=
createQueryNode
(
QNODE_TABLESCAN
,
"TableScan"
,
NULL
,
0
,
NULL
,
0
,
info
);
if
(
!
pQueryInfo
->
info
.
projectionQuery
)
{
SArray
*
p
=
pQueryInfo
->
exprList
[
0
];
STableMetaInfo
*
pTableMetaInfo1
=
getMetaInfo
(
pQueryInfo
,
0
);
// table source column projection, generate the projection expr
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
tableCols
);
SExprInfo
**
pExpr
=
calloc
(
numOfCols
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGetP
(
tableCols
,
i
);
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
tableCols
);
pNode
->
numOfExpr
=
numOfCols
;
pNode
->
pExpr
=
taosArrayInit
(
numOfCols
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
p
,
i
);
SColumn
*
pCol
=
pExprInfo
->
base
.
pColumns
;
SSourceParam
param
=
{
0
};
addIntoSourceParam
(
&
param
,
NULL
,
pCol
);
SSchema
s
=
createSchema
(
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
pCol
->
info
.
colId
,
pCol
->
name
);
SExprInfo
*
p
=
createExprInfo
(
pTableMetaInfo1
,
"project"
,
&
param
,
&
s
,
0
);
pExpr
[
i
]
=
p
;
}
SSchema
schema
=
createSchema
(
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
pCol
->
info
.
colId
,
pCol
->
name
);
pNode
=
createQueryNode
(
QNODE_PROJECT
,
"Projection"
,
&
pNode
,
1
,
pExpr
,
numOfCols
,
NULL
);
tfree
(
pExpr
);
SExprInfo
*
p
=
createExprInfo
(
pTableMetaInfo1
,
"project"
,
&
param
,
&
schema
,
0
);
taosArrayPush
(
pNode
->
pExpr
,
&
p
);
}
}
return
pNode
;
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
1a1cd551
...
...
@@ -443,7 +443,7 @@ static const char* jkExprNodeColumn = "Column";
static
const
char
*
jkExprNodeValue
=
"Value"
;
static
bool
exprNodeToJson
(
const
void
*
obj
,
cJSON
*
jExprInfo
)
{
const
tExprNode
*
exprInfo
=
(
const
tExprNode
*
)
obj
;
const
tExprNode
*
exprInfo
=
*
(
const
tExprNode
*
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
jExprInfo
,
jkExprNodeType
,
exprInfo
->
nodeType
);
if
(
res
)
{
switch
(
exprInfo
->
nodeType
)
{
...
...
@@ -531,7 +531,7 @@ static bool exprInfoToJson(const void* obj, cJSON* jExprInfo) {
const
SExprInfo
*
exprInfo
=
(
const
SExprInfo
*
)
obj
;
bool
res
=
addObject
(
jExprInfo
,
jkExprInfoBase
,
sqlExprToJson
,
&
exprInfo
->
base
);
if
(
res
)
{
res
=
addObject
(
jExprInfo
,
jkExprInfoExpr
,
exprNodeToJson
,
exprInfo
->
pExpr
);
res
=
addObject
(
jExprInfo
,
jkExprInfoExpr
,
exprNodeToJson
,
&
exprInfo
->
pExpr
);
}
return
res
;
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
1a1cd551
...
...
@@ -65,9 +65,9 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
}
if
(
pLogicPlan
->
info
.
type
!=
QNODE_MODIFY
)
{
//
char* str = NULL;
//
queryPlanToString(pLogicPlan, &str);
//
printf("%s\n", str);
char
*
str
=
NULL
;
queryPlanToString
(
pLogicPlan
,
&
str
);
printf
(
"%s
\n
"
,
str
);
}
code
=
optimizeQueryPlan
(
pLogicPlan
);
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
1a1cd551
...
...
@@ -1216,7 +1216,7 @@ int32_t schLaunchTask(SSchJob *pJob, SSchTask *pTask) {
SCH_ERR_JRET
(
code
);
}
printf
(
"physical plan:%s
\n
"
,
pTask
->
msg
);
//
printf("physical plan:%s\n", pTask->msg);
}
SCH_ERR_JRET
(
schSetTaskCandidateAddrs
(
pJob
,
pTask
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录