Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
58500a3c
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看板
提交
58500a3c
编写于
9月 17, 2021
作者:
A
AlexDuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
limit centiors count to expect range and speed up same points
上级
f651179a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
23 deletion
+28
-23
src/query/inc/tdigest.h
src/query/inc/tdigest.h
+2
-2
src/query/src/tdigest.c
src/query/src/tdigest.c
+26
-21
未找到文件。
src/query/inc/tdigest.h
浏览文件 @
58500a3c
...
...
@@ -26,11 +26,11 @@
#define M_PI 3.14159265358979323846264338327950288
/* pi */
#endif
#define ADDITION_CENTROID_NUM
100
#define ADDITION_CENTROID_NUM
2
#define COMPRESSION 400
#define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM)
#define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2))
#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SPt)*GET_THRESHOLD(compression))
#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(S
Centroid)*GET_CENTROID(compression) + sizeof(S
Pt)*GET_THRESHOLD(compression))
typedef
struct
SCentroid
{
double
mean
;
...
...
src/query/src/tdigest.c
浏览文件 @
58500a3c
...
...
@@ -29,7 +29,7 @@
#include "tdigest.h"
#define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0)))
#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (
q) - 1) + M_PI / 2) / M_PI
)
#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (
double)(q) - 1)/M_PI + (double)1/2)
)
#define FLOAT_EQ(f1, f2) (fabs((f1) - (f2)) <= FLT_EPSILON)
typedef
struct
SMergeArgs
{
...
...
@@ -78,26 +78,28 @@ static void mergeCentroid(SMergeArgs *args, SCentroid *merge) {
SCentroid
*
c
=
&
args
->
centroids
[
args
->
idx
];
args
->
weight_so_far
+=
merge
->
weight
;
k2
=
INTEGRATED_LOCATION
(
args
->
t
->
compression
,
args
->
weight_so_far
/
args
->
t
->
total_weight
);
if
(
k2
-
args
->
k1
>
1
&&
c
->
weight
>
0
)
{
if
(
args
->
idx
+
1
<
args
->
t
->
size
)
{
// check avoid overflow
args
->
idx
++
;
}
else
{
assert
(
0
);
k2
=
INTEGRATED_LOCATION
(
args
->
t
->
size
,
args
->
weight_so_far
/
(
args
->
t
->
total_weight
+
merge
->
weight
));
//idx++
if
(
k2
-
args
->
k1
>
1
&&
c
->
weight
>
0
)
{
if
(
args
->
idx
+
1
<
args
->
t
->
size
&&
merge
->
mean
!=
args
->
centroids
[
args
->
idx
].
mean
)
{
args
->
idx
++
;
}
args
->
k1
=
INTEGRATED_LOCATION
(
args
->
t
->
compression
,
(
args
->
weight_so_far
-
merge
->
weight
)
/
args
->
t
->
total_weight
);
args
->
k1
=
k2
;
}
c
=
&
args
->
centroids
[
args
->
idx
];
c
->
weight
+=
merge
->
weight
;
c
->
mean
+=
(
merge
->
mean
-
c
->
mean
)
*
merge
->
weight
/
c
->
weight
;
if
(
merge
->
weight
>
0
)
{
args
->
min
=
MIN
(
merge
->
mean
,
args
->
min
);
args
->
max
=
MAX
(
merge
->
mean
,
args
->
max
);
if
(
c
->
mean
==
merge
->
mean
)
{
c
->
weight
+=
merge
->
weight
;
}
else
{
c
->
weight
+=
merge
->
weight
;
c
->
mean
+=
(
merge
->
mean
-
c
->
mean
)
*
merge
->
weight
/
c
->
weight
;
if
(
merge
->
weight
>
0
)
{
args
->
min
=
MIN
(
merge
->
mean
,
args
->
min
);
args
->
max
=
MAX
(
merge
->
mean
,
args
->
max
);
}
}
}
...
...
@@ -163,10 +165,13 @@ void tdigestAdd(TDigest* t, double x, int64_t w) {
return
;
int32_t
i
=
t
->
num_buffered_pts
;
t
->
buffered_pts
[
i
].
value
=
x
;
t
->
buffered_pts
[
i
].
weight
=
w
;
t
->
num_buffered_pts
++
;
t
->
total_weight
+=
w
;
if
(
i
>
0
&&
t
->
buffered_pts
[
i
-
1
].
value
==
x
)
{
t
->
buffered_pts
[
i
].
weight
=
w
;
}
else
{
t
->
buffered_pts
[
i
].
value
=
x
;
t
->
buffered_pts
[
i
].
weight
=
w
;
t
->
num_buffered_pts
++
;
}
if
(
t
->
num_buffered_pts
>=
t
->
threshold
)
tdigestCompress
(
t
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录