Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
26ebf798
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看板
提交
26ebf798
编写于
3月 01, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rollbackfix error in mem order desc
上级
36837467
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
35 deletion
+52
-35
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+29
-12
src/query/src/qUtil.c
src/query/src/qUtil.c
+4
-2
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+19
-21
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
26ebf798
...
...
@@ -5504,20 +5504,35 @@ static bool tail_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResIn
static
void
tail_function
(
SQLFunctionCtx
*
pCtx
)
{
STailInfo
*
pRes
=
getOutputInfo
(
pCtx
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
if
(
pRes
->
offset
++
<
(
int32_t
)
pCtx
->
param
[
1
].
i64
){
continue
;
}
if
(
pRes
->
num
>=
(
int32_t
)
pCtx
->
param
[
0
].
i64
){
break
;
if
(
pCtx
->
stableQuery
){
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
TSKEY
ts
=
(
pCtx
->
ptsList
!=
NULL
)
?
GET_TS_DATA
(
pCtx
,
i
)
:
0
;
do_tail_function_add
(
pRes
,
(
int32_t
)(
pCtx
->
param
[
0
].
i64
+
pCtx
->
param
[
1
].
i64
),
data
,
ts
,
pCtx
->
inputBytes
,
&
pCtx
->
tagInfo
,
NULL
,
pCtx
->
currentStage
);
}
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
}
else
{
for
(
int32_t
i
=
pCtx
->
size
-
1
;
i
>=
0
;
--
i
)
{
if
(
pRes
->
offset
++
<
(
int32_t
)
pCtx
->
param
[
1
].
i64
){
continue
;
}
if
(
pRes
->
num
>=
(
int32_t
)
pCtx
->
param
[
0
].
i64
){
// query complete
pCtx
->
resultInfo
->
complete
=
true
;
for
(
int32_t
j
=
0
;
j
<
pCtx
->
tagInfo
.
numOfTagCols
;
++
j
)
{
SQLFunctionCtx
*
ctx
=
pCtx
->
tagInfo
.
pTagCtxList
[
j
];
ctx
->
resultInfo
->
complete
=
true
;
}
break
;
}
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
TSKEY
ts
=
(
pCtx
->
ptsList
!=
NULL
)
?
GET_TS_DATA
(
pCtx
,
i
)
:
0
;
TSKEY
ts
=
(
pCtx
->
ptsList
!=
NULL
)
?
GET_TS_DATA
(
pCtx
,
i
)
:
0
;
valueTailAssign
(
pRes
->
res
[
pRes
->
num
],
pCtx
->
inputBytes
,
data
,
ts
,
&
pCtx
->
tagInfo
,
NULL
,
pCtx
->
currentStage
);
valueTailAssign
(
pRes
->
res
[
pRes
->
num
],
pCtx
->
inputBytes
,
data
,
ts
,
&
pCtx
->
tagInfo
,
NULL
,
pCtx
->
currentStage
);
pRes
->
num
++
;
pRes
->
num
++
;
}
}
// treat the result as only one result
...
...
@@ -5534,7 +5549,7 @@ static void tail_func_merge(SQLFunctionCtx *pCtx) {
// the intermediate result is binary, we only use the output data type
for
(
int32_t
i
=
0
;
i
<
pInput
->
num
;
++
i
)
{
do_tail_function_add
(
pOutput
,
(
int32_t
)
pCtx
->
param
[
0
].
i64
,
pInput
->
res
[
i
]
->
data
,
pInput
->
res
[
i
]
->
timestamp
,
do_tail_function_add
(
pOutput
,
(
int32_t
)
(
pCtx
->
param
[
0
].
i64
+
pCtx
->
param
[
1
].
i64
)
,
pInput
->
res
[
i
]
->
data
,
pInput
->
res
[
i
]
->
timestamp
,
pCtx
->
outputBytes
,
&
pCtx
->
tagInfo
,
pInput
->
res
[
i
]
->
data
+
pCtx
->
outputBytes
,
pCtx
->
currentStage
);
}
...
...
@@ -5555,9 +5570,11 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
int32_t
bytes
=
0
;
int32_t
type
=
0
;
int32_t
start
=
0
;
if
(
pCtx
->
currentStage
==
MERGE_STAGE
)
{
bytes
=
pCtx
->
outputBytes
;
type
=
pCtx
->
outputType
;
start
=
pCtx
->
param
[
1
].
i64
;
assert
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BINARY
);
}
else
{
bytes
=
pCtx
->
inputBytes
;
...
...
@@ -5580,7 +5597,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
qError
(
"calloc error in tail_func_finalizer: size:%d, num:%d"
,
(
int32_t
)
size
,
GET_RES_INFO
(
pCtx
)
->
numOfRes
);
return
;
}
for
(
int32_t
start
=
pCtx
->
param
[
1
].
i64
,
i
=
0
;
start
<
pRes
->
num
;
start
++
,
i
++
){
for
(
int32_t
i
=
0
;
start
<
pRes
->
num
;
start
++
,
i
++
){
memcpy
(
data
+
i
*
size
,
pRes
->
res
[
start
],
size
);
}
taosqsort
(
data
,
(
size_t
)
GET_RES_INFO
(
pCtx
)
->
numOfRes
,
size
,
&
support
,
sortCompareFn
);
...
...
src/query/src/qUtil.c
浏览文件 @
26ebf798
...
...
@@ -38,10 +38,12 @@ int32_t getRowNumForMultioutput(SQueryAttr* pQueryAttr, bool topBottomQuery, boo
if
(
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_TOP
||
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_BOTTOM
||
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_SAMPLE
||
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_HISTOGRAM
||
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_TAIL
)
{
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_HISTOGRAM
)
{
return
(
int32_t
)
pQueryAttr
->
pExpr1
[
i
].
base
.
param
[
0
].
i64
;
}
if
(
pQueryAttr
->
pExpr1
[
i
].
base
.
functionId
==
TSDB_FUNC_TAIL
)
{
return
(
int32_t
)(
pQueryAttr
->
pExpr1
[
i
].
base
.
param
[
0
].
i64
+
pQueryAttr
->
pExpr1
[
i
].
base
.
param
[
1
].
i64
);
}
}
if
(
pQueryAttr
->
uniqueQuery
){
return
MAX_UNIQUE_RESULT_ROWS
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
26ebf798
...
...
@@ -1855,12 +1855,11 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
while
(
i
<
numOfCols
&&
(
j
<
numOfColsOfRow1
||
k
<
numOfColsOfRow2
))
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
// if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
// pData = (char*)pColInfo->pData + numOfRows * pColInfo->info.bytes;
// } else {
// pData = (char*)pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes;
// }
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
int32_t
colIdOfRow1
;
if
(
j
>=
numOfColsOfRow1
)
{
...
...
@@ -1991,12 +1990,11 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
if
(
forceSetNull
)
{
while
(
i
<
numOfCols
)
{
// the remain columns are all null data
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
// if (ASCENDING_TRAVERSE(pQueryHandle->order)) {
// pData = (char*)pColInfo->pData + numOfRows * pColInfo->info.bytes;
// } else {
// pData = (char*)pColInfo->pData + (capacity - numOfRows - 1) * pColInfo->info.bytes;
// }
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
||
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
setVardataNull
(
pData
,
pColInfo
->
info
.
type
);
...
...
@@ -2342,7 +2340,7 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
SWAP
(
cur
->
win
.
skey
,
cur
->
win
.
ekey
,
TSKEY
);
}
//
moveDataToFront(pQueryHandle, numOfRows, numOfCols);
moveDataToFront
(
pQueryHandle
,
numOfRows
,
numOfCols
);
updateInfoAfterMerge
(
pQueryHandle
,
pCheckInfo
,
numOfRows
,
pos
);
doCheckGeneratedBlockRange
(
pQueryHandle
);
...
...
@@ -2980,14 +2978,14 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
assert
(
numOfRows
<=
maxRowsToRead
);
// if the buffer is not full in case of descending order query, move the data in the front of the buffer
//
if (!ASCENDING_TRAVERSE(pQueryHandle->order) && numOfRows < maxRowsToRead) {
//
int32_t emptySize = maxRowsToRead - numOfRows;
//
//
for(int32_t i = 0; i < numOfCols; ++i) {
//
SColumnInfoData* pColInfo = taosArrayGet(pQueryHandle->pColumns, i);
//
memmove((char*)pColInfo->pData, (char*)pColInfo->pData + emptySize * pColInfo->info.bytes, numOfRows * pColInfo->info.bytes);
//
}
//
}
if
(
!
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
)
&&
numOfRows
<
maxRowsToRead
)
{
int32_t
emptySize
=
maxRowsToRead
-
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pQueryHandle
->
pColumns
,
i
);
memmove
((
char
*
)
pColInfo
->
pData
,
(
char
*
)
pColInfo
->
pData
+
emptySize
*
pColInfo
->
info
.
bytes
,
numOfRows
*
pColInfo
->
info
.
bytes
);
}
}
int64_t
elapsedTime
=
taosGetTimestampUs
()
-
st
;
tsdbDebug
(
"%p build data block from cache completed, elapsed time:%"
PRId64
" us, numOfRows:%d, numOfCols:%d, 0x%"
PRIx64
,
pQueryHandle
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录