Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ca9f4be1
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ca9f4be1
编写于
1月 05, 2023
作者:
D
dapan1121
提交者:
GitHub
1月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19370 from taosdata/enh/TD-21690
enh(query): handle getBufPage return NULL when no available disk spaces
上级
eb7b16a4
183b0002
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
286 addition
and
91 deletion
+286
-91
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+3
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+227
-75
source/libs/function/src/detail/tminmax.c
source/libs/function/src/detail/tminmax.c
+32
-10
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+24
-4
未找到文件。
source/libs/function/inc/builtinsimpl.h
浏览文件 @
ca9f4be1
...
...
@@ -44,9 +44,10 @@ typedef struct SMinmaxResInfo {
bool
nullTupleSaved
;
int16_t
type
;
}
SMinmaxResInfo
;
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
);
STuplePos
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
);
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
,
int32_t
*
nElems
);
int32_t
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STuplePos
*
pPos
);
int32_t
updateTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STuplePos
*
pPos
);
const
char
*
loadTupleData
(
SqlFunctionCtx
*
pCtx
,
const
STuplePos
*
pPos
);
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
ca9f4be1
此差异已折叠。
点击以展开。
source/libs/function/src/detail/tminmax.c
浏览文件 @
ca9f4be1
...
...
@@ -700,7 +700,7 @@ static void doExtractVal(SColumnInfoData* pCol, int32_t i, int32_t end, SqlFunct
}
}
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
)
{
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
,
int32_t
*
nElems
)
{
int32_t
numOfElems
=
0
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
...
...
@@ -745,7 +745,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
}
else
{
...
...
@@ -759,7 +762,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
}
...
...
@@ -773,7 +779,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
}
...
...
@@ -787,7 +796,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
}
...
...
@@ -803,14 +815,17 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
}
}
pBuf
->
assign
=
true
;
return
numOfElems
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
start
=
pInput
->
startRowIndex
;
...
...
@@ -824,7 +839,10 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
memcpy
(
&
pBuf
->
v
,
pCol
->
pData
+
(
pCol
->
info
.
bytes
*
i
),
pCol
->
info
.
bytes
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
&
pBuf
->
tuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
pBuf
->
assign
=
true
;
numOfElems
=
1
;
...
...
@@ -887,9 +905,13 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
_over:
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pBuf
->
nullTupleSaved
)
{
pBuf
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
int32_t
code
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
&
pBuf
->
nullTuplePos
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
pBuf
->
nullTupleSaved
=
true
;
}
return
numOfElems
;
*
nElems
=
numOfElems
;
return
TSDB_CODE_SUCCESS
;
}
source/libs/function/src/tpercentile.c
浏览文件 @
ca9f4be1
...
...
@@ -40,6 +40,9 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
int32_t
*
pageId
=
taosArrayGet
(
pIdList
,
i
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
if
(
pg
==
NULL
)
{
return
NULL
;
}
memcpy
(
buffer
->
data
+
offset
,
pg
->
data
,
(
size_t
)(
pg
->
num
*
pMemBucket
->
bytes
));
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
...
...
@@ -104,6 +107,9 @@ double findOnlyResult(tMemBucket *pMemBucket) {
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
if
(
pPage
==
NULL
)
{
return
-
1
;
}
ASSERT
(
pPage
->
num
==
1
);
double
v
=
0
;
...
...
@@ -380,6 +386,9 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
}
pSlot
->
info
.
data
=
getNewBufPage
(
pBucket
->
pBuffer
,
&
pageId
);
if
(
pSlot
->
info
.
data
==
NULL
)
{
return
TSDB_CODE_NO_AVAIL_DISK
;
}
pSlot
->
info
.
pageId
=
pageId
;
taosArrayPush
(
pPageIdList
,
&
pageId
);
}
...
...
@@ -391,7 +400,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
}
pBucket
->
total
+=
count
;
return
0
;
return
TSDB_CODE_SUCCESS
;
}
////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -471,6 +480,9 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
if
(
pSlot
->
info
.
size
<=
pMemBucket
->
maxCapacity
)
{
// data in buffer and file are merged together to be processed.
SFilePage
*
buffer
=
loadDataFromFilePage
(
pMemBucket
,
i
);
if
(
buffer
==
NULL
)
{
return
-
1
;
}
int32_t
currentIdx
=
count
-
num
;
char
*
thisVal
=
buffer
->
data
+
pMemBucket
->
bytes
*
currentIdx
;
...
...
@@ -505,8 +517,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
for
(
int32_t
f
=
0
;
f
<
list
->
size
;
++
f
)
{
int32_t
*
pageId
=
taosArrayGet
(
list
,
f
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
if
(
pg
==
NULL
)
{
return
-
1
;
}
tMemBucketPut
(
pMemBucket
,
pg
->
data
,
(
int32_t
)
pg
->
num
);
int32_t
code
=
tMemBucketPut
(
pMemBucket
,
pg
->
data
,
(
int32_t
)
pg
->
num
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
setBufPageDirty
(
pg
,
true
);
releaseBufPage
(
pMemBucket
->
pBuffer
,
pg
);
}
...
...
@@ -528,7 +546,9 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
// if only one elements exists, return it
if
(
pMemBucket
->
total
==
1
)
{
return
findOnlyResult
(
pMemBucket
);
if
(
findOnlyResult
(
pMemBucket
)
<
0
)
{
return
-
1
;
}
}
percent
=
fabs
(
percent
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录