Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eae188b4
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看板
提交
eae188b4
编写于
1月 06, 2023
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix no available disk error
上级
77bbbdc7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
36 deletion
+36
-36
source/libs/function/inc/tpercentile.h
source/libs/function/inc/tpercentile.h
+2
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+5
-6
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+29
-28
未找到文件。
source/libs/function/inc/tpercentile.h
浏览文件 @
eae188b4
...
...
@@ -73,10 +73,10 @@ void tMemBucketDestroy(tMemBucket *pBucket);
int32_t
tMemBucketPut
(
tMemBucket
*
pBucket
,
const
void
*
data
,
size_t
size
);
double
getPercentile
(
tMemBucket
*
pMemBucket
,
double
percen
t
);
int32_t
getPercentile
(
tMemBucket
*
pMemBucket
,
double
percent
,
double
*
resul
t
);
#endif // TDENGINE_TPERCENTILE_H
#ifdef __cplusplus
}
#endif
\ No newline at end of file
#endif
source/libs/function/src/builtinsimpl.c
浏览文件 @
eae188b4
...
...
@@ -1670,15 +1670,14 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
if
(
pMemBucket
!=
NULL
&&
pMemBucket
->
total
>
0
)
{
// check for null
SET_DOUBLE_VAL
(
&
ppInfo
->
result
,
getPercentile
(
pMemBucket
,
v
));
int32_t
code
=
getPercentile
(
pMemBucket
,
v
,
&
ppInfo
->
result
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tMemBucketDestroy
(
pMemBucket
);
return
code
;
}
}
tMemBucketDestroy
(
pMemBucket
);
if
(
ppInfo
->
result
<
0
)
{
return
TSDB_CODE_NO_AVAIL_DISK
;
}
return
functionFinalize
(
pCtx
,
pBlock
);
}
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
eae188b4
...
...
@@ -97,7 +97,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
pInfo
->
data
=
NULL
;
}
double
findOnlyResult
(
tMemBucket
*
pMemBucke
t
)
{
int32_t
findOnlyResult
(
tMemBucket
*
pMemBucket
,
double
*
resul
t
)
{
ASSERT
(
pMemBucket
->
total
==
1
);
for
(
int32_t
i
=
0
;
i
<
pMemBucket
->
numOfSlots
;
++
i
)
{
...
...
@@ -115,17 +115,17 @@ double findOnlyResult(tMemBucket *pMemBucket) {
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
if
(
pPage
==
NULL
)
{
return
-
1
;
return
TSDB_CODE_NO_AVAIL_DISK
;
}
ASSERT
(
pPage
->
num
==
1
);
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pMemBucket
->
type
,
pPage
->
data
);
return
v
;
GET_TYPED_DATA
(
*
result
,
double
,
pMemBucket
->
type
,
pPage
->
data
);
return
TSDB_CODE_SUCCESS
;
}
}
return
0
;
*
result
=
0
.
0
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
tBucketIntHash
(
tMemBucket
*
pBucket
,
const
void
*
value
)
{
...
...
@@ -447,7 +447,7 @@ static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) {
return
finalResult
;
}
double
getPercentileImpl
(
tMemBucket
*
pMemBucket
,
int32_t
count
,
double
fraction
)
{
int32_t
getPercentileImpl
(
tMemBucket
*
pMemBucket
,
int32_t
count
,
double
fraction
,
double
*
result
)
{
int32_t
num
=
0
;
for
(
int32_t
i
=
0
;
i
<
pMemBucket
->
numOfSlots
;
++
i
)
{
...
...
@@ -480,15 +480,15 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
ASSERT
(
minOfNextSlot
>
maxOfThisSlot
);
double
val
=
(
1
-
fraction
)
*
maxOfThisSlot
+
fraction
*
minOfNextSlot
;
return
val
;
*
result
=
(
1
-
fraction
)
*
maxOfThisSlot
+
fraction
*
minOfNextSlot
;
return
TSDB_CODE_SUCCESS
;
}
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
;
return
TSDB_CODE_NO_AVAIL_DISK
;
}
int32_t
currentIdx
=
count
-
num
;
...
...
@@ -499,13 +499,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
GET_TYPED_DATA
(
td
,
double
,
pMemBucket
->
type
,
thisVal
);
GET_TYPED_DATA
(
nd
,
double
,
pMemBucket
->
type
,
nextVal
);
double
val
=
(
1
-
fraction
)
*
td
+
fraction
*
nd
;
*
result
=
(
1
-
fraction
)
*
td
+
fraction
*
nd
;
taosMemoryFreeClear
(
buffer
);
return
val
;
return
TSDB_CODE_SUCCESS
;
}
else
{
// incur a second round bucket split
if
(
isIdenticalData
(
pMemBucket
,
i
))
{
return
getIdenticalDataVal
(
pMemBucket
,
i
);
*
result
=
getIdenticalDataVal
(
pMemBucket
,
i
);
return
TSDB_CODE_SUCCESS
;
}
// try next round
...
...
@@ -534,37 +535,37 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
int32_t
*
pageId
=
taosArrayGet
(
list
,
f
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
if
(
pg
==
NULL
)
{
return
-
1
;
return
TSDB_CODE_NO_AVAIL_DISK
;
}
int32_t
code
=
tMemBucketPut
(
pMemBucket
,
pg
->
data
,
(
int32_t
)
pg
->
num
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
return
code
;
}
setBufPageDirty
(
pg
,
true
);
releaseBufPage
(
pMemBucket
->
pBuffer
,
pg
);
}
return
getPercentileImpl
(
pMemBucket
,
count
-
num
,
fraction
);
return
getPercentileImpl
(
pMemBucket
,
count
-
num
,
fraction
,
result
);
}
}
else
{
num
+=
pSlot
->
info
.
size
;
}
}
return
0
;
*
result
=
0
;
return
TSDB_CODE_SUCCESS
;
}
double
getPercentile
(
tMemBucket
*
pMemBucket
,
double
percen
t
)
{
int32_t
getPercentile
(
tMemBucket
*
pMemBucket
,
double
percent
,
double
*
resul
t
)
{
if
(
pMemBucket
->
total
==
0
)
{
return
0
.
0
;
*
result
=
0
.
0
;
return
TSDB_CODE_SUCCESS
;
}
// if only one elements exists, return it
if
(
pMemBucket
->
total
==
1
)
{
if
(
findOnlyResult
(
pMemBucket
)
<
0
)
{
return
-
1
;
}
return
findOnlyResult
(
pMemBucket
,
result
);
}
percent
=
fabs
(
percent
);
...
...
@@ -574,21 +575,21 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
MinMaxEntry
*
pRange
=
&
pMemBucket
->
range
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
i64MaxVal
:
pRange
->
i64MinVal
);
return
v
;
*
result
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
i64MaxVal
:
pRange
->
i64MinVal
);
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
u64MaxVal
:
pRange
->
u64MinVal
);
return
v
;
*
result
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
u64MaxVal
:
pRange
->
u64MinVal
);
}
else
{
return
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
*
result
=
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
}
return
TSDB_CODE_SUCCESS
;
}
double
percentVal
=
(
percent
*
(
pMemBucket
->
total
-
1
))
/
((
double
)
100
.
0
);
// do put data by using buckets
int32_t
orderIdx
=
(
int32_t
)
percentVal
;
return
getPercentileImpl
(
pMemBucket
,
orderIdx
,
percentVal
-
orderIdx
);
return
getPercentileImpl
(
pMemBucket
,
orderIdx
,
percentVal
-
orderIdx
,
result
);
}
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录