Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
812c9bcc
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看板
提交
812c9bcc
编写于
7月 11, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-5176]<enhance>: improve the twa query performance in case of interval query.
上级
c9933fd3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
76 deletion
+62
-76
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+58
-70
src/query/src/qUtil.c
src/query/src/qUtil.c
+2
-4
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
812c9bcc
...
...
@@ -105,7 +105,7 @@ typedef struct SResultRowInfo {
int16_t
type
:
8
;
// data type for hash key
int32_t
size
:
24
;
// number of result set
int32_t
capacity
;
// max capacity
SResultRow
*
current
;
// current active result row
int32_t
curPos
;
// current active result row index of pResult list
}
SResultRowInfo
;
typedef
struct
SColumnFilterElem
{
...
...
@@ -423,7 +423,7 @@ typedef struct STagScanInfo {
SColumnInfo
*
pCols
;
SSDataBlock
*
pRes
;
int32_t
totalTables
;
int32_t
cur
rentIndex
;
int32_t
cur
Pos
;
}
STagScanInfo
;
typedef
struct
SOptrBasicInfo
{
...
...
src/query/src/qExecutor.c
浏览文件 @
812c9bcc
...
...
@@ -411,8 +411,8 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, SQueryRuntim
pResultRowInfo
->
capacity
=
(
int32_t
)
newCapacity
;
}
static
SResultRow
*
doPrepareResultRowFromKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
tableGroupId
)
{
static
SResultRow
*
doSetResultOutBufByKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
tableGroupId
)
{
bool
existed
=
false
;
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
tableGroupId
);
...
...
@@ -426,16 +426,21 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
}
if
(
p1
!=
NULL
)
{
pResultRowInfo
->
current
=
(
*
p1
);
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_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
tid
);
void
*
ptr
=
taosHashGet
(
pRuntimeEnv
->
pResultRowListSet
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
existed
=
(
ptr
!=
NULL
);
int64_t
*
index
=
taosHashGet
(
pRuntimeEnv
->
pResultRowListSet
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
if
(
index
!=
NULL
)
{
pResultRowInfo
->
curPos
=
(
int32_t
)
*
index
;
existed
=
true
;
}
else
{
existed
=
false
;
}
}
}
}
else
{
...
...
@@ -462,12 +467,12 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
pResult
=
*
p1
;
}
pResultRowInfo
->
curPos
=
pResultRowInfo
->
size
;
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
++
]
=
pResult
;
pResultRowInfo
->
current
=
pResult
;
int64_t
dummyVal
=
0
;
int64_t
index
=
pResultRowInfo
->
curPos
;
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
tid
);
taosHashPut
(
pRuntimeEnv
->
pResultRowListSet
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
dummyVal
,
POINTER_BYTES
);
taosHashPut
(
pRuntimeEnv
->
pResultRowListSet
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
index
,
POINTER_BYTES
);
}
// too many time window in query
...
...
@@ -475,7 +480,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SRes
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW
);
}
return
pResultRowInfo
->
current
;
return
pResultRowInfo
->
pResult
[
pResultRowInfo
->
curPos
]
;
}
static
void
getInitialStartTimeWindow
(
SQueryAttr
*
pQueryAttr
,
TSKEY
ts
,
STimeWindow
*
w
)
{
...
...
@@ -506,13 +511,8 @@ static void getInitialStartTimeWindow(SQueryAttr* pQueryAttr, TSKEY ts, STimeWin
static
STimeWindow
getActiveTimeWindow
(
SResultRowInfo
*
pResultRowInfo
,
int64_t
ts
,
SQueryAttr
*
pQueryAttr
)
{
STimeWindow
w
=
{
0
};
if
(
pResultRowInfo
->
current
==
NULL
)
{
// the first window, from the previous stored value
// if (pResultRowInfo->prevSKey == TSKEY_INITIAL_VAL) {
getInitialStartTimeWindow
(
pQueryAttr
,
ts
,
&
w
);
// pResultRowInfo->prevSKey = w.skey;
// } else {
// w.skey = pResultRowInfo->prevSKey;
// }
if
(
pResultRowInfo
->
curPos
==
-
1
)
{
// the first window, from the previous stored value
getInitialStartTimeWindow
(
pQueryAttr
,
ts
,
&
w
);
if
(
pQueryAttr
->
interval
.
intervalUnit
==
'n'
||
pQueryAttr
->
interval
.
intervalUnit
==
'y'
)
{
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pQueryAttr
->
interval
.
interval
,
pQueryAttr
->
interval
.
intervalUnit
,
pQueryAttr
->
precision
)
-
1
;
...
...
@@ -520,7 +520,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
w
.
ekey
=
w
.
skey
+
pQueryAttr
->
interval
.
interval
-
1
;
}
}
else
{
w
=
pResultRowInfo
->
current
->
win
;
w
=
getResultRow
(
pResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
}
if
(
w
.
skey
>
ts
||
w
.
ekey
<
ts
)
{
...
...
@@ -600,13 +600,13 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
return
0
;
}
static
int32_t
set
Window
OutputBufByKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
STimeWindow
*
win
,
static
int32_t
set
Result
OutputBufByKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
SQLFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
SResultRow
*
pResultRow
=
do
PrepareResultRowFrom
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
tableGroupId
);
SResultRow
*
pResultRow
=
do
SetResultOutBufBy
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
tableGroupId
);
if
(
pResultRow
==
NULL
)
{
*
pResult
=
NULL
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -707,9 +707,10 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
if
(
skey
==
TSKEY_INITIAL_VAL
)
{
if
(
pResultRowInfo
->
size
==
0
)
{
// assert(pResultRowInfo->current == NULL);
pResultRowInfo
->
current
=
NULL
;
assert
(
pResultRowInfo
->
curPos
==
-
1
);
pResultRowInfo
->
curPos
=
-
1
;
}
else
{
pResultRowInfo
->
cur
rent
=
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
-
1
]
;
pResultRowInfo
->
cur
Pos
=
pResultRowInfo
->
size
-
1
;
}
}
else
{
...
...
@@ -721,9 +722,9 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
}
if
(
i
==
pResultRowInfo
->
size
-
1
)
{
pResultRowInfo
->
cur
rent
=
pResultRowInfo
->
pResult
[
i
]
;
pResultRowInfo
->
cur
Pos
=
i
;
}
else
{
pResultRowInfo
->
cur
rent
=
pResultRowInfo
->
pResult
[
i
+
1
]
;
// current not closed result object
pResultRowInfo
->
cur
Pos
=
i
+
1
;
// current not closed result object
}
}
}
...
...
@@ -732,7 +733,7 @@ static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, SQuer
bool
ascQuery
=
QUERY_IS_ASC_QUERY
(
pQueryAttr
);
if
((
lastKey
>
pQueryAttr
->
window
.
ekey
&&
ascQuery
)
||
(
lastKey
<
pQueryAttr
->
window
.
ekey
&&
(
!
ascQuery
)))
{
closeAllResultRows
(
pResultRowInfo
);
pResultRowInfo
->
cur
rent
=
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
-
1
]
;
pResultRowInfo
->
cur
Pos
=
pResultRowInfo
->
size
-
1
;
}
else
{
int32_t
step
=
ascQuery
?
1
:
-
1
;
doUpdateResultRowIndex
(
pResultRowInfo
,
lastKey
-
step
,
ascQuery
,
pQueryAttr
->
timeWindowInterpo
);
...
...
@@ -1241,7 +1242,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pQueryAttr
->
order
.
order
);
bool
ascQuery
=
QUERY_IS_ASC_QUERY
(
pQueryAttr
);
SResultRow
*
prevRow
=
pResultRowInfo
->
current
;
int32_t
prevIndex
=
pResultRowInfo
->
curPos
;
TSKEY
*
tsCols
=
NULL
;
if
(
pSDataBlock
->
pDataBlock
!=
NULL
)
{
...
...
@@ -1258,7 +1259,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
SResultRow
*
pResult
=
NULL
;
int32_t
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
int32_t
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
numOfOutput
,
pInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -1270,25 +1271,17 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
getNumOfRowsInTimeWindow
(
pRuntimeEnv
,
&
pSDataBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
true
);
// prev time window not interpolation yet.
// int32_t curIndex = curTimeWindowIndex(pResultRowInfo);
// if (prevIndex != -1 && prevIndex < curIndex && pQueryAttr->timeWindowInterpo) {
// for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
if
(
prevRow
!=
NULL
&&
prevRow
!=
pResultRowInfo
->
current
&&
pQueryAttr
->
timeWindowInterpo
)
{
int32_t
j
=
0
;
while
(
pResultRowInfo
->
pResult
[
j
]
!=
prevRow
)
{
j
++
;
}
SResultRow
*
current
=
pResultRowInfo
->
current
;
for
(;
pResultRowInfo
->
pResult
[
j
]
!=
current
&&
j
<
pResultRowInfo
->
size
;
++
j
)
{
SResultRow
*
pRes
=
pResultRowInfo
->
pResult
[
j
];
int32_t
curIndex
=
pResultRowInfo
->
curPos
;
if
(
prevIndex
!=
-
1
&&
prevIndex
<
curIndex
&&
pQueryAttr
->
timeWindowInterpo
)
{
for
(
int32_t
j
=
prevIndex
;
j
<
curIndex
;
++
j
)
{
// previous time window may be all closed already.
SResultRow
*
pRes
=
getResultRow
(
pResultRowInfo
,
j
);
if
(
pRes
->
closed
)
{
assert
(
resultRowInterpolated
(
pRes
,
RESULT_ROW_START_INTERP
)
&&
resultRowInterpolated
(
pRes
,
RESULT_ROW_END_INTERP
));
continue
;
}
STimeWindow
w
=
pRes
->
win
;
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
w
,
masterScan
,
&
pResult
,
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
w
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
numOfOutput
,
pInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -1306,7 +1299,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
}
// restore current time window
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
numOfOutput
,
pInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -1326,7 +1319,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
}
// null data, failed to allocate more memory buffer
int32_t
code
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
nextWin
,
masterScan
,
&
pResult
,
tableGroupId
,
int32_t
code
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
nextWin
,
masterScan
,
&
pResult
,
tableGroupId
,
pInfo
->
pCtx
,
numOfOutput
,
pInfo
->
rowCellInfoOffset
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -1467,7 +1460,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
SResultRow
*
pResult
=
NULL
;
pInfo
->
curWindow
.
ekey
=
pInfo
->
curWindow
.
skey
;
int32_t
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
int32_t
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
&
pResult
,
item
->
groupIndex
,
pBInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pBInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
...
...
@@ -1488,7 +1481,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
SResultRow
*
pResult
=
NULL
;
pInfo
->
curWindow
.
ekey
=
pInfo
->
curWindow
.
skey
;
int32_t
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
int32_t
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
&
pResult
,
item
->
groupIndex
,
pBInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pBInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
...
...
@@ -1532,7 +1525,7 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic
}
int64_t
tid
=
0
;
SResultRow
*
pResultRow
=
do
PrepareResultRowFrom
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
d
,
len
,
true
,
groupIndex
);
SResultRow
*
pResultRow
=
do
SetResultOutBufBy
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
d
,
len
,
true
,
groupIndex
);
assert
(
pResultRow
!=
NULL
);
setResultRowKey
(
pResultRow
,
pData
,
type
);
...
...
@@ -2779,7 +2772,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
TSKEY
k
=
ascQuery
?
pBlock
->
info
.
window
.
skey
:
pBlock
->
info
.
window
.
ekey
;
STimeWindow
win
=
getActiveTimeWindow
(
pTableScanInfo
->
pResultRowInfo
,
k
,
pQueryAttr
);
if
(
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pTableScanInfo
->
pResultRowInfo
,
pBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
groupId
,
if
(
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pTableScanInfo
->
pResultRowInfo
,
pBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
groupId
,
pTableScanInfo
->
pCtx
,
pTableScanInfo
->
numOfOutput
,
pTableScanInfo
->
rowCellInfoOffset
)
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -2825,7 +2818,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
TSKEY
k
=
ascQuery
?
pBlock
->
info
.
window
.
skey
:
pBlock
->
info
.
window
.
ekey
;
STimeWindow
win
=
getActiveTimeWindow
(
pTableScanInfo
->
pResultRowInfo
,
k
,
pQueryAttr
);
if
(
set
Window
OutputBufByKey
(
pRuntimeEnv
,
pTableScanInfo
->
pResultRowInfo
,
pBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
groupId
,
if
(
set
Result
OutputBufByKey
(
pRuntimeEnv
,
pTableScanInfo
->
pResultRowInfo
,
pBlock
->
info
.
tid
,
&
win
,
masterScan
,
&
pResult
,
groupId
,
pTableScanInfo
->
pCtx
,
pTableScanInfo
->
numOfOutput
,
pTableScanInfo
->
rowCellInfoOffset
)
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -3181,11 +3174,11 @@ static void updateTableQueryInfoForReverseScan(STableQueryInfo *pTableQueryInfo)
pTableQueryInfo
->
cur
.
vgroupIndex
=
-
1
;
// set the index to be the end slot of result rows array
SResultRowInfo
*
pResRowInfo
=
&
pTableQueryInfo
->
resInfo
;
if
(
pResRowInfo
->
size
>
0
)
{
pRes
RowInfo
->
current
=
pResRowInfo
->
pResult
[
pResRowInfo
->
size
-
1
]
;
SResultRowInfo
*
pRes
ult
RowInfo
=
&
pTableQueryInfo
->
resInfo
;
if
(
pRes
ult
RowInfo
->
size
>
0
)
{
pRes
ultRowInfo
->
curPos
=
pResultRowInfo
->
size
-
1
;
}
else
{
pRes
RowInfo
->
current
=
NULL
;
pRes
ultRowInfo
->
curPos
=
-
1
;
}
}
...
...
@@ -3240,7 +3233,7 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
int64_t
tid
=
0
;
SResultRow
*
pRow
=
do
PrepareResultRowFrom
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
tid
,
sizeof
(
tid
),
true
,
uid
);
SResultRow
*
pRow
=
do
SetResultOutBufBy
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
tid
,
sizeof
(
tid
),
true
,
uid
);
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
...
...
@@ -3477,7 +3470,7 @@ void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pRe
int64_t
tid
=
0
;
SResultRow
*
pResultRow
=
do
PrepareResultRowFrom
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
tableGroupId
,
sizeof
(
tableGroupId
),
true
,
uid
);
do
SetResultOutBufBy
Key
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
tableGroupId
,
sizeof
(
tableGroupId
),
true
,
uid
);
assert
(
pResultRow
!=
NULL
);
/*
...
...
@@ -3680,14 +3673,10 @@ void setIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key) {
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
SResultRowInfo
*
pResultRowInfo
=
&
pTableQueryInfo
->
resInfo
;
if
(
pResultRowInfo
->
cur
rent
!=
NULL
)
{
if
(
pResultRowInfo
->
cur
Pos
!=
-
1
)
{
return
;
}
// if (pWindowResInfo->prevSKey != TSKEY_INITIAL_VAL) {
// return;
// }
pTableQueryInfo
->
win
.
skey
=
key
;
STimeWindow
win
=
{.
skey
=
key
,
.
ekey
=
pQueryAttr
->
window
.
ekey
};
...
...
@@ -4609,8 +4598,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
}
if
(
pResultRowInfo
->
size
>
0
)
{
pResultRowInfo
->
current
=
pResultRowInfo
->
pResult
[
0
];
// pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey;
pResultRowInfo
->
curPos
=
0
;
}
qDebug
(
"QInfo:0x%"
PRIx64
" start to repeat scan data blocks due to query func required, qrange:%"
PRId64
"-%"
PRId64
,
...
...
@@ -4635,8 +4623,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) {
pTableScanInfo
->
order
=
cond
.
order
;
if
(
pResultRowInfo
->
size
>
0
)
{
pResultRowInfo
->
current
=
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
-
1
];
// pResultRowInfo->prevSKey = pResultRowInfo->current->win.skey;
pResultRowInfo
->
curPos
=
pResultRowInfo
->
size
-
1
;
}
p
=
doTableScanImpl
(
pOperator
,
newgroup
);
...
...
@@ -5496,7 +5483,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
}
else
{
SResultRow
*
pResult
=
NULL
;
pInfo
->
curWindow
.
ekey
=
pInfo
->
curWindow
.
skey
;
int32_t
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
int32_t
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
&
pResult
,
item
->
groupIndex
,
pBInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pBInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
...
...
@@ -5513,10 +5500,11 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
}
}
SResultRow
*
pResult
=
NULL
;
pInfo
->
curWindow
.
ekey
=
pInfo
->
curWindow
.
skey
;
int32_t
ret
=
set
Window
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
int32_t
ret
=
set
Result
OutputBufByKey
(
pRuntimeEnv
,
&
pBInfo
->
resultRowInfo
,
pSDataBlock
->
info
.
tid
,
&
pInfo
->
curWindow
,
masterScan
,
&
pResult
,
item
->
groupIndex
,
pBInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pBInfo
->
rowCellInfoOffset
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
...
...
@@ -6294,8 +6282,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pRes
->
pDataBlock
,
0
);
while
(
pInfo
->
cur
rentIndex
<
pInfo
->
totalTables
&&
count
<
maxNumOfTables
)
{
int32_t
i
=
pInfo
->
cur
rentIndex
++
;
while
(
pInfo
->
cur
Pos
<
pInfo
->
totalTables
&&
count
<
maxNumOfTables
)
{
int32_t
i
=
pInfo
->
cur
Pos
++
;
STableQueryInfo
*
item
=
taosArrayGetP
(
pa
,
i
);
char
*
output
=
pColInfo
->
pData
+
count
*
rsize
;
...
...
@@ -6339,8 +6327,8 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
SExprInfo
*
pExprInfo
=
pOperator
->
pExpr
;
// todo use the column list instead of exprinfo
count
=
0
;
while
(
pInfo
->
cur
rentIndex
<
pInfo
->
totalTables
&&
count
<
maxNumOfTables
)
{
int32_t
i
=
pInfo
->
cur
rentIndex
++
;
while
(
pInfo
->
cur
Pos
<
pInfo
->
totalTables
&&
count
<
maxNumOfTables
)
{
int32_t
i
=
pInfo
->
cur
Pos
++
;
STableQueryInfo
*
item
=
taosArrayGetP
(
pa
,
i
);
...
...
@@ -6369,7 +6357,7 @@ static SSDataBlock* doTagScan(void* param, bool* newgroup) {
count
+=
1
;
}
if
(
pInfo
->
cur
rentIndex
>=
pInfo
->
totalTables
)
{
if
(
pInfo
->
cur
Pos
>=
pInfo
->
totalTables
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
}
...
...
@@ -6388,7 +6376,7 @@ SOperatorInfo* createTagScanOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SExprInf
assert
(
numOfGroup
==
0
||
numOfGroup
==
1
);
pInfo
->
totalTables
=
pRuntimeEnv
->
tableqinfoGroupInfo
.
numOfTables
;
pInfo
->
cur
rentIndex
=
0
;
pInfo
->
cur
Pos
=
0
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"SeqTableTagScan"
;
...
...
src/query/src/qUtil.c
浏览文件 @
812c9bcc
...
...
@@ -44,8 +44,7 @@ int32_t getOutputInterResultBufSize(SQueryAttr* pQueryAttr) {
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
,
int16_t
type
)
{
pResultRowInfo
->
type
=
type
;
pResultRowInfo
->
size
=
0
;
// pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL;
pResultRowInfo
->
current
=
NULL
;
pResultRowInfo
->
curPos
=
-
1
;
pResultRowInfo
->
capacity
=
size
;
pResultRowInfo
->
pResult
=
calloc
(
pResultRowInfo
->
capacity
,
POINTER_BYTES
);
...
...
@@ -92,8 +91,7 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
}
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
current
=
NULL
;
// pResultRowInfo->prevSKey = TSKEY_INITIAL_VAL;
pResultRowInfo
->
curPos
=
-
1
;
}
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录