Hudi cleaning-异步操作

参数配置

设置参数,在建表的时候指定:

配置型设定值
hoodie.clean.automaticfalse
hoodie.clean.asynctrue
hoodie.cleaner.commits.retained1

建表语句

create table small_file_hudi_cow (
  id int,
  name string,
  age int,
  city STRING,
  date_str STRING
) using hudi
tblproperties (
  type = 'cow',
  primaryKey = 'id',
  preCombineField = 'id',
  'hoodie.clean.automatic' = 'false',
  'hoodie.clean.async' = 'true',
  'hoodie.cleaner.commits.retained' = '1'
)
partitioned by (date_str);

操作执行计划

步骤操作文件系统导入或者更新数据的命令
1insertbase fileINSERT INTO small_file_hudi_cow SELECT id, name, age, city, event_date FROM sample_data_partitioned where event_date='2023-11-03';
1updatebase fileINSERT INTO small_file_hudi_cow SELECT id, name, age, city, event_date FROM sample_data_partitioned where event_date='2023-11-03';
1updatebase fileINSERT INTO small_file_hudi_cow SELECT id, name, age, city, event_date FROM sample_data_partitioned where event_date='2023-11-03';

 第一步insert 

在第一次往表里面插入数据的时候,会产生第一个版本文件和时间记录信息,具体如下:

第二步 update数据

由于数据全量更新第一次的所有数据文件

第三步update 

由于全量更新第一次的所有数据文件,更新后添加对应的一组 file 信息。其文件信息及时间线如下:

第四步 Cleaning

执行脚本:

spark-submit --class org.apache.hudi.utilities.HoodieCleaner /data/axiang/hudi-0.14.0/hudi-bundle/hudi-utilities-bundle_2.12-0.14.0.jar \
  --target-base-path /user/hive/warehouse/axiang_hudi.db/small_file_hudi_cow/ \
  --hoodie-conf hoodie.cleaner.policy=KEEP_LATEST_COMMITS \
  --hoodie-conf hoodie.cleaner.commits.retained=1 \
  --hoodie-conf hoodie.cleaner.parallelism=200 \
  --hoodie-conf hoodie.clean.async=true \
  --hoodie-conf hoodie.clean.automatic=false

执行完成后,会生成一个clean 的时间线。同时删除历史版本的数据。其文件信息及时间线如下:

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值