Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

distinct count目前存在的问题以及改进思路 #78

@muyannian

Description

@muyannian

@刘宏凯 @孙磊 distinct count 对应的java实现类为 DistinctCount.java
性能瓶颈在这个地方

reFilter这个方法频繁创建和释放map,有非常大的性能优化空间
因数据量的变化,以及group by的组数变化(参考ajust)都会调整抽样比率,每次抽样比率变化都会导致调用reFilter,如何减少计算量一直减少对象的频繁创建以及释放对性能影响致关重要

目前的抽样比率是这样变化的 1>2>4>8>16>32...
最简单的减少reFilter次数的方法为 抽样比率变化加快 1>16>32>64>128的这种的 ,但不是理想解决方案

简单修改下 refilter的实现吧 作为commiter提交给我
这个类 不到400行的代码,大家应该能轻松搞定

孤独侠客加入本群

开心延年 2014/7/4 10:25:41
频繁full gc 的原因 跟refilter 有直接关系

开心延年 2014/7/4 10:26:06
private void reFilter(int times) {
if (this.currentTimes == times) {
return;
}

    this.currentTimes = times;
    TIntHashSet data = DistinctCount.createmap();

    for (Integer ucrc : this.uniq.toArray()) {
        if (this.isallow(ucrc)) {
            data.add(ucrc);
        }
    }
    this.uniq = data;
}

稻草人
2014/7/4 10:26:10
full gc 这个事情对我们的系统影响特别大
10:26:34
开心延年 2014/7/4 10:26:34
这个代码的实现 特别土鳖的 如果大家 真想用 distinct count,改造下这个方法吧

开心延年 2014/7/4 10:26:58
他的目的仅仅是 移除 不符合抽样类型的 数据
wzc1989
2014/7/4 10:27:08
求 distinct 实现背景介绍。。。没准我可以捣鼓一下。。

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions