提交 281746c1 编写于 作者: A AlexDuan

addition 3 centriods and check overflow

上级 61c75fe0
......@@ -27,7 +27,7 @@
#endif
#define COMPRESSION 400
#define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1)
#define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + 3) // addition 3 centroid
#define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2))
#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression))
......
......@@ -78,7 +78,9 @@ static void mergeCentroid(SMergeArgs *args, SCentroid *merge) {
args->weight_so_far / args->t->total_weight);
if (k2 - args->k1 > 1 && c->weight > 0) {
args->idx++;
if(args->idx + 1 < args->t->size) { // check avoid overflow
args->idx++;
}
args->k1 = INTEGRATED_LOCATION(args->t->compression,
(args->weight_so_far - merge->weight) / args->t->total_weight);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册