Dandandan commented on code in PR #1181:
URL: https://github.com/apache/datafusion-comet/pull/1181#discussion_r1892442856
##########
native/core/src/execution/shuffle/shuffle_writer.rs:
##########
@@ -1543,14 +1569,38 @@ pub(crate) fn write_ipc_compressed<W: Write + Seek>(
// write ipc_length placeholder
output.write_all(&[0u8; 8])?;
- // write ipc data
- // TODO: make compression level configurable
- let mut arrow_writer = StreamWriter::try_new(zstd::Encoder::new(output,
1)?, &batch.schema())?;
- arrow_writer.write(batch)?;
- arrow_writer.finish()?;
+ let output = match codec {
+ CompressionCodec::Lz4 => {
+ // write IPC first without compression
+ let mut buffer = vec![];
+ let mut arrow_writer = StreamWriter::try_new(&mut buffer,
&batch.schema())?;
+ arrow_writer.write(batch)?;
+ arrow_writer.finish()?;
+ let ipc_encoded = arrow_writer.into_inner()?;
+
+ let mut encoder = lz4::EncoderBuilder::new()
+ .content_size(ipc_encoded.len() as u64)
+ .checksum(ContentChecksum::ChecksumEnabled)
+ .block_checksum(BlockChecksum::BlockChecksumEnabled)
+ .level(4)
+ .block_size(BlockSize::Default)
+ .auto_flush(true)
+ .build(&mut *output)?;
+ encoder.write_all(ipc_encoded.as_slice())?;
+ let (output, result) = encoder.finish();
+ result?;
+ output
+ }
+ CompressionCodec::Zstd(level) => {
+ let encoder = zstd::Encoder::new(output, *level)?;
+ let mut arrow_writer = StreamWriter::try_new(encoder,
&batch.schema())?;
Review Comment:
Besides writing the schema each time, I guess it will also have higher
overhead of flushing each time (less efficient buffering), having lower
compressibility, etc. ?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]