Repository navigation
Add CompressionCodecAdaptive with per-block codec selection - #111134
Conversation
|
Workflow [PR], commit [f1862a3] Summary: ✅
AI ReviewSummaryThis PR adds the internal Findings
Final VerdictChanges requested. |
| friend int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size); | ||
|
|
||
| /// Return size of compressed data without header | ||
| /// Upper bound on the compressed data size without the header. While compressing, a codec may temporarily write more bytes |
There was a problem hiding this comment.
Old contract was incorrect
| return false; | ||
| } | ||
|
|
||
| bool CompressionCodecMultiple::isEncryption() const |
There was a problem hiding this comment.
Wasn't needed before. Now it is because someone can set default_compression_codec to be a chain of codecs one of which uses encryption. In that case, we wouldn't want adaptivity to work, even if it is on and CODEC(Default) is selected for the column
| : pool(AdaptiveCodec::poolForType(type, deployment_default)) | ||
| { | ||
| chassert(!pool.empty()); | ||
| setCodecDescription("Adaptive"); |
There was a problem hiding this comment.
setCodecDescription("Adaptive") makes this wrapper look like a normal codec family, but Adaptive is not registered in CompressionCodecFactory. Unchanged MergeTree writer code round-trips default_codec through getFullCodecDesc() for columns without an explicit CODEC and immediately feeds that AST back into CompressionCodecFactory::get(...) when it builds the stream codec, so the first implicit-default stream would fail with UNKNOWN_CODEC as soon as this wrapper is passed via the existing default_codec slot. If it ever reaches disk, default_compression_codec.txt has the same round-trip problem on part load and falls back to "detect one codec from data", which does not preserve per-block adaptivity. This needs either a descriptor that round-trips through the existing codec interfaces or a separate path that never serializes/reparses CODEC(Adaptive).
There was a problem hiding this comment.
This doesn't make much sense. CODEC(Adaptive) doesn't and won't exist. Adaptive is never recorded on disk. We record in metadata that default codec was used and within the blocks the actually used codec.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 234/245 (95.51%) · Uncovered code |
| const bool is_smaller = size < best_size; | ||
| best_idx = is_smaller ? i : best_idx; | ||
| best_size = is_smaller ? size : best_size; |
There was a problem hiding this comment.
do we need ternary operator here?
There was a problem hiding this comment.
Makes no difference here: https://godbolt.org/z/v8cY7Wzca. I can change it if you want
There was a problem hiding this comment.
I think it will be better without ternary
rienath
left a comment
There was a problem hiding this comment.
Thanks @Michicosun. I've replied all the comments. Could you let me know if we can merge?
| const bool is_smaller = size < best_size; | ||
| best_idx = is_smaller ? i : best_idx; | ||
| best_size = is_smaller ? size : best_size; |
There was a problem hiding this comment.
Makes no difference here: https://godbolt.org/z/v8cY7Wzca. I can change it if you want
|
He did in real life: yes |
|
@rienath End user docs (under a big bold "experimental" banner) please :-) |
|
Will do, thanks @rschu1ze |
Add `CompressionCodecAdaptive` with per-block codec selection
CompressionCodecAdaptivepicks the smallest-output codec for each block from a pool (NONE, the deployment default, and type-appropriate candidates) and compresses the block with it. Candidates are priced byCompressedSizeCalculator(#109054). A codec that can compute its compressed size is priced without compressing, the rest compress into scratch and are measured. The winner's method byte lands on disk, so readers decode each block with no knowledge of the wrapper.This is the selection core of the RFC (#105404): how
CODEC(Default)resolves per block. Nothing constructs the codec yet, a follow-up wires it into merges and mutations behind an experimental setting.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Version info
26.8.1.98(included in26.8and later)