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)
相关推荐
喵了几个咪4 天前
Apache Doris 4.x 在量化交易中的完整应用实践
ai·doris·量化交易
piepis5 天前
Doris 快速写入原理
doris
AllData公司负责人14 天前
高效同步!离线开发平台(DolphinScheduler) 实现Apache IotDB物联网数据同步到 Doris
apache·doris·iotdb
jasnet_u21 天前
Doris的集群搭建(3FE+3BE)
doris·mpp
家有娇妻张兔兔23 天前
Apache Doris 副本故障排查与修复实战指南
apache·doris·时序库
秦拿希2 个月前
【doris】doris部署
doris
linweidong2 个月前
别让老板等:千人并发下的实时大屏极致性能优化实录
jmeter·clickhouse·性能优化·sentinel·doris·物化视图·离线数仓
北方的银狐-Zero2 个月前
记录第一次部署银河麒麟环境Apache Doris单机部署
sql·database·doris
千桐科技2 个月前
qData 数据中台开源版 1.1.2 版本更新公告:新增 Apache Doris 数据源全面支持,稽查规则与转换组件持续完善
开源软件·数据治理·doris·数据集成·大数据平台·数据中台·qdata
leoZ2313 个月前
# Apache Doris FE Docker 启动问题排错与解决总结
doris