Ronitsabhaya75 opened a new pull request, #23172:
URL: https://github.com/apache/kafka/pull/23172

   This PR implements the optional Content Size field in the LZ4 frame header 
as defined by the LZ4 Frame Format specification.
   
   Previously, `Lz4BlockOutputStream` had a TODO to write the uncompressed 
content size. This change:
   - Adds a new constructor to `Lz4BlockOutputStream` that accepts an optional 
`contentSize` parameter.
   - Updates the `FLG` byte to set the content size flag (bit 3) when a valid 
size is provided.
   - Writes the 8-byte little-endian content size between the BD byte and the 
HC checksum in the header.
   
   The existing constructors are left unchanged and default to omitting the 
content size, ensuring full backward compatibility. `Lz4BlockInputStream` 
already correctly skips these bytes when the flag is set.
   
   Testing Strategy:
   Added new unit tests in `Lz4CompressionTest`:
   - `testContentSizeWrittenInHeader`: Verifies the FLG bit is set and the 
8-byte content size is correctly formatted in the header.
   - `testContentSizeRoundTrip`: Ensures successful round-trip compression and 
decompression when the content size is included.
   - `testDefaultConstructorOmitsContentSize`: Confirms existing default 
constructors do not set the flag and maintain the original 7-byte header format.
   


-- 
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]

Reply via email to