Repository navigation
feat(arrow-ipc): make lz4 block size configurable - #12148
Conversation
Rich-T-kid
left a comment
There was a problem hiding this comment.
I think this change should be much smaller. It may be a good idea to split up the reader side from the writer side
|
Yeah sir will work on 85 nd make the changess |
|
is this ready for another review? |
|
@Rich-T-kid |
|
@Rich-T-kid sir now you can have a look and feel free to admit any changes to done by my side the ci checks greens |
|
will take another look this afternoon |
|
@Rich-T-kid for sure no worries ill be happy to address if u suggest any changes and take ur time to look on this issue |
|
Thanks for the review @Rich-T-kid . I linked the LZ4 frame specification . removed the redundant comments, and updated the encoder comment to explain why the selected block size is pinned. I also changed the test to reuse one IpcWriteContext while switching block sizes, and kept the round-trip checks. I haven’t been able to run the test locally yet because my MSVC toolchain is missing link.exe. |
|
@mohitgurav20 can you resolve the threads that you have addressed. it just makes it easier for me. 🙇 |
|
Yeah wait for a while sir get back to it easier to understand |
07abfd0 to
b64fbb1
Compare
|
@Rich-T-kid done sir i have addressed the changes just waiting for ci checks to turn green . u can have a look on it |
Allow callers to choose 64 KiB / 256 KiB / 1 MiB / 4 MiB lz4 blocks via IpcWriteOptions, keeping 256 KiB as the default pinned by apache#12084. 8 MiB is excluded because the frame header's 3-bit block size code cannot represent it without setting the reserved bit, which the decoder rejects. Generated-by: MiMo via OpenCode
Represent supported block sizes with an internal enum, reduce redundant tests, and reject ZSTD regardless of builder call order. Generated-by: Codex (GPT-6)
Link the frame specification, remove redundant comments, and reuse one IPC write context across block sizes in the end-to-end test. Generated-by: Codex Desktop v26.1105.1297
b64fbb1 to
b951020
Compare
Rich-T-kid
left a comment
There was a problem hiding this comment.
thanks for the iteration @mohitgurav20, this should be good to go after addressing the two comments
| /// [`ArrowError::InvalidArgumentError`]. Like the other compression settings this requires | ||
| /// metadata version V5 or newer, and it has no effect when another compression codec is | ||
| /// selected. |
There was a problem hiding this comment.
combining this with ZSTD returns an error
There was a problem hiding this comment.
Yeahh sirr will work on this thanks for the help
There was a problem hiding this comment.
Yes, that combination returns an error. The builder checks the selected codec regardless of call order, and the tests cover setting ZSTD before and after the LZ4 block size.
There was a problem hiding this comment.
@mohitgurav20 could you point that out in the doc comment
| @@ -27,7 +27,7 @@ use arrow_data::{ArrayData, ArrayDataBuilder, BufferSpec, layout}; | |||
| use arrow_schema::*; | |||
There was a problem hiding this comment.
nit: this does have a public facing change as there a new method, could you update the pr description
|
Thanks for the review @Rich-T-kid sirr I’ve updated the PR description to mention the new public method, and confirmed that combining the LZ4 block-size option with ZSTD returns an error in either builder-call order. Please let me know if you’d like any further changes, I’m happy to address them |
Rich-T-kid
left a comment
There was a problem hiding this comment.
thank you for the iteration @mohitgurav20
|
@Rich-T-kid sir i hv updated the docs to clarify that an LZ4 block size can’t be combined with ZSTD, regardless of which option is set first. I also noted that the block size can be cleared with None before selecting ZSTD. Thanks for catching that. |
|
have a nice day sir |
Which issue does this PR close?
Rationale for this change
#12084 pinned the reusable LZ4 frame encoder to a 256 KiB block size so a reused encoder’s block size is not decided by the first buffer it writes. Callers who want to trade retained encoder buffers against compression ratio currently have no way to choose a different size. This change lets callers configure the block size while keeping 256 KiB as the default, so existing output remains unchanged.
What changes are included in this PR?
IpcWriteOptions::try_with_lz4_block_size(Option<usize>), following the existingtry_with_compression_levelpattern with a private field and validating builder.IpcWriteContextto store the selected size and discard its cached encoder when that size changes. The setting is synced through the shared record batch and dictionary batch encoding path.Lz4Compressorrebuilds after a mid-frame error.lz4_flexsets a reserved frame-header bit for that size, which its decoder rejects.Are these changes tested?
Tests cover the supported frame-header size codes and roundtrips, byte-identical output for the default 256 KiB setting, and switching block sizes while reusing an
IpcWriteContext. They also cover unsupported sizes, metadata V4, ZSTD in both builder-call orders, and end-to-end roundtrips with nulls and a dictionary column.Are there any significant user-facing changes?
Yes. This adds the public
IpcWriteOptions::try_with_lz4_block_sizemethod so callers can select an LZ4 frame block size. The addition is non-breaking; when the option is unset, the 256 KiB default and encoded output are unchanged.AI usage disclosure
Codex Desktop and OpenCode assisted with implementation, test updates, and reviewer-driven revisions. I guided the changes based on the issue and reviewer feedback. The branch was checked with local tests, formatting, and lint.