Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
ab5b0d57
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
未验证
提交
ab5b0d57
编写于
2月 29, 2020
作者:
P
plum-lihui
提交者:
GitHub
2月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1281 from taosdata/feature/liaohj
Feature/liaohj
上级
4a9e27d6
bf3abcc0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
49 deletion
+52
-49
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-1
src/inc/tresultBuf.h
src/inc/tresultBuf.h
+1
-1
src/system/detail/inc/vnodeQueryImpl.h
src/system/detail/inc/vnodeQueryImpl.h
+2
-2
src/system/detail/src/vnodeQueryImpl.c
src/system/detail/src/vnodeQueryImpl.c
+42
-44
src/util/src/tresultBuf.c
src/util/src/tresultBuf.c
+1
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
ab5b0d57
...
...
@@ -584,9 +584,14 @@ static bool isTopBottomQuery(SQueryInfo* pQueryInfo) {
int32_t
parseIntervalClause
(
SQueryInfo
*
pQueryInfo
,
SQuerySQL
*
pQuerySql
)
{
const
char
*
msg1
=
"invalid query expression"
;
const
char
*
msg2
=
"interval cannot be less than 10 ms"
;
const
char
*
msg3
=
"interval required"
;
SMeterMetaInfo
*
pMeterMetaInfo
=
tscGetMeterMetaInfoFromQueryInfo
(
pQueryInfo
,
0
);
if
(
pQuerySql
->
interval
.
type
==
0
&&
pQuerySql
->
sliding
.
type
!=
0
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
if
(
pQuerySql
->
interval
.
type
==
0
||
pQuerySql
->
interval
.
n
==
0
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
src/inc/tresultBuf.h
浏览文件 @
ab5b0d57
...
...
@@ -88,7 +88,7 @@ int32_t getNumOfResultBufGroupId(SQueryDiskbasedResultBuf* pResultBuf);
* destroy result buffer
* @param pResultBuf
*/
void
destroyResultBuf
(
SQueryDiskbasedResultBuf
*
pResultBuf
);
void
destroy
Diskbased
ResultBuf
(
SQueryDiskbasedResultBuf
*
pResultBuf
);
/**
*
...
...
src/system/detail/inc/vnodeQueryImpl.h
浏览文件 @
ab5b0d57
...
...
@@ -277,9 +277,9 @@ void copyTimeWindowResBuf(SQueryRuntimeEnv* pRuntimeEnv, SWindowResult* dst, con
int32_t
initWindowResInfo
(
SWindowResInfo
*
pWindowResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
size
,
int32_t
threshold
,
int16_t
type
);
void
cleanupTimeWindowInfo
(
SWindowResInfo
*
pWindowResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
);
void
cleanupTimeWindowInfo
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
numOfCols
);
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SWindowResInfo
*
pWindowResInfo
);
void
clearFirstNTimeWindow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
num
);
void
clearFirstNTimeWindow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
num
);
void
clearClosedTimeWindow
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
int32_t
numOfClosedTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
...
...
src/system/detail/src/vnodeQueryImpl.c
浏览文件 @
ab5b0d57
...
...
@@ -585,7 +585,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, int64_t StartQue
void
createQueryResultInfo
(
SQuery
*
pQuery
,
SWindowResult
*
pResultRow
,
bool
isSTableQuery
,
SPosInfo
*
posInfo
);
static
void
destroyTimeWindowRes
(
SWindowResult
*
p
OneOutput
Res
,
int32_t
nOutputCols
);
static
void
destroyTimeWindowRes
(
SWindowResult
*
p
Window
Res
,
int32_t
nOutputCols
);
static
int32_t
binarySearchForBlockImpl
(
SCompBlock
*
pBlock
,
int32_t
numOfBlocks
,
TSKEY
skey
,
int32_t
order
)
{
int32_t
firstSlot
=
0
;
...
...
@@ -1740,7 +1740,8 @@ static void doBlockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SWindowStat
pCtx
[
k
].
nStartQueryTimestamp
=
pWin
->
skey
;
pCtx
[
k
].
size
=
forwardStep
;
pCtx
[
k
].
startOffset
=
(
QUERY_IS_ASC_QUERY
(
pQuery
))
?
startPos
:
startPos
-
(
forwardStep
-
1
);
pCtx
[
k
].
ptsList
=
(
TSKEY
*
)((
char
*
)
pRuntimeEnv
->
primaryColBuffer
->
data
+
pCtx
[
k
].
startOffset
*
TSDB_KEYSIZE
);
int32_t
functionId
=
pQuery
->
pSelectExpr
[
k
].
pBase
.
functionId
;
if
(
functionNeedToExecute
(
pRuntimeEnv
,
&
pCtx
[
k
],
functionId
))
{
aAggs
[
functionId
].
xFunction
(
&
pCtx
[
k
]);
...
...
@@ -1785,7 +1786,19 @@ static int32_t getNextQualifiedWindow(SQueryRuntimeEnv *pRuntimeEnv, STimeWindow
return
-
1
;
}
TSKEY
startKey
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pNextWin
->
skey
:
pNextWin
->
ekey
;
TSKEY
startKey
=
-
1
;
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
startKey
=
pNextWin
->
skey
;
if
(
startKey
<
pQuery
->
skey
)
{
startKey
=
pQuery
->
skey
;
}
}
else
{
startKey
=
pNextWin
->
ekey
;
if
(
startKey
>
pQuery
->
skey
)
{
startKey
=
pQuery
->
skey
;
}
}
int32_t
startPos
=
searchFn
((
char
*
)
primaryKeys
,
pBlockInfo
->
size
,
startKey
,
pQuery
->
order
.
order
);
/*
...
...
@@ -2008,10 +2021,6 @@ static bool needToLoadDataBlock(SQuery *pQuery, SField *pField, SQLFunctionCtx *
int32_t
initWindowResInfo
(
SWindowResInfo
*
pWindowResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
size
,
int32_t
threshold
,
int16_t
type
)
{
if
(
size
<
threshold
)
{
size
=
threshold
;
}
pWindowResInfo
->
capacity
=
size
;
pWindowResInfo
->
threshold
=
threshold
;
...
...
@@ -2025,7 +2034,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
// use the pointer arraylist
pWindowResInfo
->
pResult
=
calloc
(
threshold
,
sizeof
(
SWindowResult
));
for
(
int32_t
i
=
0
;
i
<
threshold
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
capacity
;
++
i
)
{
SPosInfo
posInfo
=
{
-
1
,
-
1
};
createQueryResultInfo
(
pRuntimeEnv
->
pQuery
,
&
pWindowResInfo
->
pResult
[
i
],
pRuntimeEnv
->
stableQuery
,
&
posInfo
);
}
...
...
@@ -2033,15 +2042,15 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
return
TSDB_CODE_SUCCESS
;
}
void
cleanupTimeWindowInfo
(
SWindowResInfo
*
pWindowResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
void
cleanupTimeWindowInfo
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
numOfCols
)
{
if
(
pWindowResInfo
==
NULL
||
pWindowResInfo
->
capacity
==
0
)
{
assert
(
pWindowResInfo
->
hashList
==
NULL
&&
pWindowResInfo
->
pResult
==
NULL
);
return
;
}
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
capacity
;
++
i
)
{
SWindowResult
*
pResult
=
&
pWindowResInfo
->
pResult
[
i
];
destroyTimeWindowRes
(
pResult
,
pRuntimeEnv
->
pQuery
->
numOfOutput
Cols
);
destroyTimeWindowRes
(
pResult
,
numOf
Cols
);
}
taosCleanUpHashTable
(
pWindowResInfo
->
hashList
);
...
...
@@ -2846,16 +2855,18 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
return
;
}
dTrace
(
"QInfo:%p teardown runtime env"
,
GET_QINFO_ADDR
(
pRuntimeEnv
->
pQuery
));
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfCols
;
++
i
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
dTrace
(
"QInfo:%p teardown runtime env"
,
GET_QINFO_ADDR
(
pQuery
));
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfCols
;
++
i
)
{
tfree
(
pRuntimeEnv
->
colDataBuffer
[
i
]);
}
tfree
(
pRuntimeEnv
->
secondaryUnzipBuffer
);
cleanupTimeWindowInfo
(
&
pRuntimeEnv
->
windowResInfo
,
p
RuntimeEnv
);
cleanupTimeWindowInfo
(
&
pRuntimeEnv
->
windowResInfo
,
p
Query
->
numOfOutputCols
);
if
(
pRuntimeEnv
->
pCtx
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
p
RuntimeEnv
->
p
Query
->
numOfOutputCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
for
(
int32_t
j
=
0
;
j
<
pCtx
->
numOfParams
;
++
j
)
{
...
...
@@ -2873,7 +2884,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
tfree
(
pRuntimeEnv
->
unzipBuffer
);
if
(
p
RuntimeEnv
->
pQuery
&&
(
!
PRIMARY_TSCOL_LOADED
(
pRuntimeEnv
->
pQuery
)))
{
if
(
p
Query
&&
(
!
PRIMARY_TSCOL_LOADED
(
pQuery
)))
{
tfree
(
pRuntimeEnv
->
primaryColBuffer
);
}
...
...
@@ -2887,13 +2898,14 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
taosDestoryInterpoInfo
(
&
pRuntimeEnv
->
interpoInfo
);
if
(
pRuntimeEnv
->
pInterpoBuf
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
p
RuntimeEnv
->
p
Query
->
numOfOutputCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
tfree
(
pRuntimeEnv
->
pInterpoBuf
[
i
]);
}
tfree
(
pRuntimeEnv
->
pInterpoBuf
);
}
destroyDiskbasedResultBuf
(
pRuntimeEnv
->
pResultBuf
);
pRuntimeEnv
->
pTSBuf
=
tsBufDestory
(
pRuntimeEnv
->
pTSBuf
);
}
...
...
@@ -4504,19 +4516,19 @@ static void allocMemForInterpo(STableQuerySupportObj *pSupporter, SQuery *pQuery
static
int32_t
getInitialPageNum
(
STableQuerySupportObj
*
pSupporter
)
{
SQuery
*
pQuery
=
pSupporter
->
runtimeEnv
.
pQuery
;
int32_t
INITIAL_RESULT_ROWS_VALUE
=
16
;
int32_t
num
=
0
;
if
(
isGroupbyNormalCol
(
pQuery
->
pGroupbyExpr
))
{
num
=
128
;
}
else
if
(
isIntervalQuery
(
pQuery
))
{
// time window query, allocate one page for each table
num
=
pSupporter
->
numOfMeters
;
num
=
MAX
(
pSupporter
->
numOfMeters
,
INITIAL_RESULT_ROWS_VALUE
)
;
}
else
{
// for super table query, one page for each subset
num
=
pSupporter
->
pSidSet
->
numOfSubSet
;
}
assert
(
num
>
0
);
return
num
;
}
...
...
@@ -4816,20 +4828,6 @@ void vnodeQueryFreeQInfoEx(SQInfo *pQInfo) {
pSupporter
->
pMetersHashTable
=
NULL
;
}
if
(
pSupporter
->
pSidSet
!=
NULL
||
isGroupbyNormalCol
(
pQInfo
->
query
.
pGroupbyExpr
)
||
isIntervalQuery
(
pQuery
))
{
int32_t
size
=
0
;
if
(
isGroupbyNormalCol
(
pQInfo
->
query
.
pGroupbyExpr
)
||
isIntervalQuery
(
pQuery
))
{
size
=
10000
;
}
else
if
(
pSupporter
->
pSidSet
!=
NULL
)
{
size
=
pSupporter
->
pSidSet
->
numOfSubSet
;
}
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
// destroyTimeWindowRes(&pSupporter->pResult[i], pQInfo->query.numOfOutputCols);
}
}
tSidSetDestroy
(
&
pSupporter
->
pSidSet
);
if
(
pSupporter
->
pMeterDataInfo
!=
NULL
)
{
...
...
@@ -5874,10 +5872,13 @@ int32_t doMergeMetersResultsToGroupRes(STableQuerySupportObj *pSupporter, SQuery
tfree
(
pTree
);
tfree
(
pTableList
);
tfree
(
posList
);
tfree
(
pResultInfo
);
pSupporter
->
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutputCols
;
++
i
)
{
tfree
(
pResultInfo
[
i
].
interResultBuf
);
}
tfree
(
pResultInfo
);
return
pSupporter
->
numOfGroupResultPages
;
}
...
...
@@ -6345,6 +6346,7 @@ void vnodeScanAllData(SQueryRuntimeEnv *pRuntimeEnv) {
int64_t
skey
=
pQuery
->
lastKey
;
int32_t
status
=
pQuery
->
over
;
int32_t
activeSlot
=
pRuntimeEnv
->
windowResInfo
.
curIndex
;
SET_MASTER_SCAN_FLAG
(
pRuntimeEnv
);
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQuery
->
order
.
order
);
...
...
@@ -6370,6 +6372,7 @@ void vnodeScanAllData(SQueryRuntimeEnv *pRuntimeEnv) {
status
=
pQuery
->
over
;
pQuery
->
ekey
=
pQuery
->
lastKey
-
step
;
pQuery
->
lastKey
=
pQuery
->
skey
;
pRuntimeEnv
->
windowResInfo
.
curIndex
=
activeSlot
;
setQueryStatus
(
pQuery
,
QUERY_NOT_COMPLETED
);
pRuntimeEnv
->
scanFlag
=
REPEAT_SCAN
;
...
...
@@ -6629,13 +6632,8 @@ void destroyMeterQueryInfo(SMeterQueryInfo *pMeterQueryInfo, int32_t numOfCols)
if
(
pMeterQueryInfo
==
NULL
)
{
return
;
}
// free(pMeterQueryInfo->pageList);
// for (int32_t i = 0; i < numOfCols; ++i) {
// tfree(pMeterQueryInfo->[i].interResultBuf);
// }
// free(pMeterQueryInfo->resultInfo);
cleanupTimeWindowInfo
(
&
pMeterQueryInfo
->
windowResInfo
,
numOfCols
);
free
(
pMeterQueryInfo
);
}
...
...
src/util/src/tresultBuf.c
浏览文件 @
ab5b0d57
...
...
@@ -189,7 +189,7 @@ SIDList getDataBufPagesIdList(SQueryDiskbasedResultBuf* pResultBuf, int32_t grou
}
}
void
destroyResultBuf
(
SQueryDiskbasedResultBuf
*
pResultBuf
)
{
void
destroy
Diskbased
ResultBuf
(
SQueryDiskbasedResultBuf
*
pResultBuf
)
{
if
(
pResultBuf
==
NULL
)
{
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录