This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch miniz_oxide_improvements
in repository https://gitbox.apache.org/repos/asf/avro-rs.git

commit 8b3a5f12b3dffcc684b82d9c6669202f79667459
Author: Martin Tzvetanov Grigorov <[email protected]>
AuthorDate: Mon Apr 7 11:49:51 2025 +0300

    Issue #173 - Use non-default compression level for Codec::Deflate
    
    Add some Rustdoc
    
    Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
---
 avro/src/codec.rs    | 9 +++++++--
 avro/tests/codecs.rs | 5 ++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/avro/src/codec.rs b/avro/src/codec.rs
index 434ea7b..d9912dd 100644
--- a/avro/src/codec.rs
+++ b/avro/src/codec.rs
@@ -19,18 +19,20 @@
 use crate::{types::Value, AvroResult, Error};
 use strum_macros::{EnumIter, EnumString, IntoStaticStr};
 
+/// Settings for the `Deflate` codec.
 #[derive(Clone, Copy, Eq, PartialEq, Debug)]
 pub struct DeflateSettings {
     compression_level: miniz_oxide::deflate::CompressionLevel,
 }
 
 impl DeflateSettings {
-    fn new(compression_level: miniz_oxide::deflate::CompressionLevel) -> Self {
+    pub fn new(compression_level: miniz_oxide::deflate::CompressionLevel) -> 
Self {
         DeflateSettings { compression_level }
     }
 }
 
 impl Default for DeflateSettings {
+    /// Default compression level is 
`miniz_oxide::deflate::CompressionLevel::DefaultCompression`.
     fn default() -> Self {
         Self::new(miniz_oxide::deflate::CompressionLevel::DefaultCompression)
     }
@@ -279,6 +281,7 @@ pub mod xz {
 mod tests {
     use super::*;
     use apache_avro_test_helper::TestResult;
+    use miniz_oxide::deflate::CompressionLevel;
     use pretty_assertions::{assert_eq, assert_ne};
 
     const INPUT: &[u8] = 
b"theanswertolifetheuniverseandeverythingis42theanswertolifetheuniverseandeverythingis4theanswertolifetheuniverseandeverythingis2";
@@ -296,7 +299,9 @@ mod tests {
 
     #[test]
     fn deflate_compress_and_decompress() -> TestResult {
-        compress_and_decompress(Codec::Deflate(DeflateSettings::default()))
+        compress_and_decompress(Codec::Deflate(DeflateSettings::new(
+            CompressionLevel::BestCompression,
+        )))
     }
 
     #[cfg(feature = "snappy")]
diff --git a/avro/tests/codecs.rs b/avro/tests/codecs.rs
index 1612ca3..02137e9 100644
--- a/avro/tests/codecs.rs
+++ b/avro/tests/codecs.rs
@@ -20,6 +20,7 @@ use apache_avro::{
     Codec, DeflateSettings, Reader, Schema, Writer,
 };
 use apache_avro_test_helper::TestResult;
+use miniz_oxide::deflate::CompressionLevel;
 
 #[test]
 fn avro_4032_null_codec_settings() -> TestResult {
@@ -27,7 +28,9 @@ fn avro_4032_null_codec_settings() -> TestResult {
 }
 #[test]
 fn avro_4032_deflate_codec_settings() -> TestResult {
-    avro_4032_codec_settings(Codec::Deflate(DeflateSettings::default()))
+    avro_4032_codec_settings(Codec::Deflate(DeflateSettings::new(
+        CompressionLevel::UberCompression,
+    )))
 }
 
 #[test]

Reply via email to