Hudi Compaction
Scenarios
Hudi compaction merges base and log files in MOR tables to optimize data files, improving query performance and storage efficiency.
For MOR tables, data is stored in columnar Parquet files and row-based Avro files, updates are recorded in incremental files, and then a synchronous or asynchronous compaction is performed to generate new versions of columnar files. MOR tables can reduce data ingestion latency, so an asynchronous compaction that does not block ingestion is useful.
Performing Compaction
Compaction can be synchronous or asynchronous.
- Disable synchronous compaction.
When a data source is written, run the .option("hoodie.compact.inline", "false") command to disable automatic compaction.
When you use Spark SQL to write data, run the set hoodie.compact.inline=false; command to disable automatic compaction.
- Only compaction scheduling is generated synchronously, but compaction is not executed.
- Configure the following option parameters to write to a data source:
option("hoodie.compact.inline", "true"). option("hoodie.schedule.compact.only.inline", "true"). option("hoodie.run.compact.only.inline", "false"). - When you use·Spark SQL to write data, configure the following set parameters:
set hoodie.compact.inline=true; set hoodie.schedule.compact.only.inline=true; set hoodie.run.compact.only.inline=false;
- Configure the following option parameters to write to a data source:
- Scheduling a compaction: A compaction is completed by the job of importing data into the data lake. In this step, Hudi scans partitions and selects the file slices to be compacted. A compaction plan is finally written to the Hudi timeline.
- Executing a compaction: A separate process or thread reads the compaction plan and performs the compaction of file slices.
Spark SQL implements asynchronous mode. For details, see COMPACTION.
To execute an existing compaction scheduling plan without generating a new one during asynchronous compaction, run the set commands to configure the following parameters:
set hoodie.compact.inline=true; set hoodie.schedule.compact.only.inline=false; set hoodie.run.compact.only.inline=true;
For more compaction parameters, see Compaction and Cleaning Configurations.
To ensure the maximum efficiency of data import into the lake, you are advised to generate compaction scheduling plans synchronously and execute compaction scheduling plans asynchronously.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot