prathik-onehouse opened a new pull request, #20810: URL: https://github.com/apache/hudi/pull/20810
### Describe the issue this Pull Request addresses closes #20809 The record index and secondary index file group counts assume a fixed 48-byte entry, so tables with long keys start with file groups past their target and tables with short or compressible keys start half empty. ### Summary and Changelog The entry size is now estimated per table when the index is initialized: - Global record index: `v + keyFactor * r * keyBytes`, where `keyBytes` and the compression ratio `r` come from the `_hoodie_record_key` column of a sample of base file footers, and `v`, the compressed cost of the values, is evaluated from the table's file slices. - Secondary index: a sample of its keys, taken in the pass that already counts them, is laid out and compressed the way the HFiles store them. - Tables without meta fields, tables without usable footers and the partitioned record index keep 48 bytes. - New advanced configs: `hoodie.metadata.record.index.average.record.size` to set the size by hand, and `hoodie.metadata.record.index.entry.size.key.factor` (default 1.3). Against real HFiles at 1M rows, the record index estimate lands 4% to 26% over for UUID, random, hex and partitioned tables, and the secondary index estimate 0% to 5% over across low and high cardinality, string, numeric and timestamp columns. Keys whose neighbours differ in a few characters, such as some composite keys, can be estimated up to about 20% short, which the config doc notes. ### Impact New tables get record index and secondary index file group counts that follow their keys. Existing indexes are unchanged. Index initialization reads up to 100 base file footers for the global record index. ### Risk Level low. Only the file group count chosen at initialization changes; tests cover the estimators, the fallbacks, the override and the end-to-end file group counts. ### Documentation Update The two new configs are documented in `HoodieMetadataConfig`. ### Contributor's checklist - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [x] Enough context is provided in the sections above - [x] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
