martin-g commented on code in PR #169:
URL: https://github.com/apache/avro-rs/pull/169#discussion_r2022150795


##########
avro/src/codec.rs:
##########
@@ -120,14 +115,20 @@ impl Codec {
     pub fn decompress(self, stream: &mut Vec<u8>) -> AvroResult<()> {
         *stream = match self {
             Codec::Null => return Ok(()),
-            Codec::Deflate => {
-                let mut decoded = Vec::new();
-                let mut decoder = Decoder::new(&stream[..]);
-                decoder
-                    .read_to_end(&mut decoded)
-                    .map_err(Error::DeflateDecompress)?;
-                decoded
-            }
+            Codec::Deflate => 
miniz_oxide::inflate::decompress_to_vec(stream).map_err(|e| {
+                use miniz_oxide::inflate::TINFLStatus;
+                use std::io::ErrorKind;
+                let err_kind = match e.status {
+                    TINFLStatus::FailedCannotMakeProgress => 
ErrorKind::UnexpectedEof,
+                    TINFLStatus::BadParam => unreachable!(), // not possible 
for _to_vec()

Review Comment:
   These 'unreachable's make me feel nervous. 
   A library should not panic!
   Better introduce a new error variant! Something like Error::Unexpected("An 
unexpected error occurred. Please report it 
https://github.com/apache/avro-ra/issues";). With some info about the cause 
would be perfect!



##########
avro/src/codec.rs:
##########
@@ -61,13 +61,8 @@ impl Codec {
         match self {
             Codec::Null => (),
             Codec::Deflate => {
-                let mut encoder = Encoder::new(Vec::new());
-                encoder.write_all(stream).map_err(Error::DeflateCompress)?;
-                // Deflate errors seem to just be io::Error
-                *stream = encoder
-                    .finish()
-                    .into_result()
-                    .map_err(Error::DeflateCompressFinish)?;
+                let compressed = miniz_oxide::deflate::compress_to_vec(stream, 
6);

Review Comment:
   What is '6' here?
   The compression level ?
   Could we introduce settings like the other impls ?



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