doris:HLL

HLL是用作模糊去重,在数据量大的情况性能优于 Count Distinct。HLL的导入需要结合hll_hash等函数来使用。更多文档参考HLL

使用示例

第 1 步:准备数据

创建如下的 csv 文件:test_hll.csv

复制代码
1001|koga
1002|nijg
1003|lojn
1004|lofn
1005|jfin
1006|kon
1007|nhga
1008|nfubg
1009|huang
1010|buag

第 2 步:在库中创建表

复制代码
CREATE TABLE testdb.test_hll(
    typ_id           BIGINT          NULL   COMMENT "ID",
    typ_name         VARCHAR(10)     NULL   COMMENT "NAME",
    pv               hll hll_union   NOT NULL   COMMENT "hll"
)
AGGREGATE KEY(typ_id,typ_name)
DISTRIBUTED BY HASH(typ_id) BUCKETS 10;

第 3 步:导入数据

复制代码
curl --location-trusted -u <doris_user>:<doris_password> \
    -H "column_separator:|" \
    -H "columns:typ_id,typ_name,pv=hll_hash(typ_id)" \
    -T test_hll.csv \
    -XPUT http://<fe_ip>:<fe_http_port>/api/testdb/test_hll/_stream_load

第 4 步:检查导入数据

使用 hll_cardinality 进行查询:

复制代码
mysql> select typ_id,typ_name,hll_cardinality(pv) from testdb.test_hll;
+--------+----------+---------------------+
| typ_id | typ_name | hll_cardinality(pv) |
+--------+----------+---------------------+
|   1010 | buag     |                   1 |
|   1002 | nijg     |                   1 |
|   1001 | koga     |                   1 |
|   1008 | nfubg    |                   1 |
|   1005 | jfin     |                   1 |
|   1009 | huang    |                   1 |
|   1004 | lofn     |                   1 |
|   1007 | nhga     |                   1 |
|   1003 | lojn     |                   1 |
|   1006 | kon      |                   1 |
+--------+----------+---------------------+
10 rows in set (0.06 sec)
相关推荐
jasnet_u4 天前
Doris的集群搭建(3FE+3BE)
doris·mpp
家有娇妻张兔兔6 天前
Apache Doris 副本故障排查与修复实战指南
apache·doris·时序库
秦拿希1 个月前
【doris】doris部署
doris
linweidong1 个月前
别让老板等:千人并发下的实时大屏极致性能优化实录
jmeter·clickhouse·性能优化·sentinel·doris·物化视图·离线数仓
北方的银狐-Zero2 个月前
记录第一次部署银河麒麟环境Apache Doris单机部署
sql·database·doris
千桐科技2 个月前
qData 数据中台开源版 1.1.2 版本更新公告:新增 Apache Doris 数据源全面支持,稽查规则与转换组件持续完善
开源软件·数据治理·doris·数据集成·大数据平台·数据中台·qdata
leoZ2312 个月前
# Apache Doris FE Docker 启动问题排错与解决总结
doris
li.wz3 个月前
溯源数据清洗:一次由“可控”到“失控”的复盘
java·后端·doris
大数据追光猿3 个月前
【大数据Doris】生产环境,Doris主键模型全表7000万数据更新写入为什么那么慢?
大数据·经验分享·笔记·性能优化·doris
二进制_博客3 个月前
Doris2.x连载文章(4)
doris·mpp数据库·doris2.x