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

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


The following commit(s) were added to refs/heads/main by this push:
     new 61953fe  feat!: Serde human-readable is `false` by default (#325)
61953fe is described below

commit 61953fe4799c4155d4c2fbf0cb01960239ecac27
Author: Kriskras99 <[email protected]>
AuthorDate: Tue Oct 28 22:13:01 2025 +0100

    feat!: Serde human-readable is `false` by default (#325)
    
    This makes output files smaller when Serde is used for serialisation.
    
    To revert to the old behaviour call `set_serde_human_readable(true)`.
---
 avro/src/de.rs         |  6 +++---
 avro/src/ser.rs        |  6 +++---
 avro/src/ser_schema.rs | 19 +++++++------------
 avro/src/util.rs       |  2 +-
 4 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/avro/src/de.rs b/avro/src/de.rs
index 5b3013f..92a3b68 100644
--- a/avro/src/de.rs
+++ b/avro/src/de.rs
@@ -1538,14 +1538,14 @@ mod tests {
     }
 
     #[test]
-    fn avro_3747_human_readable_true() -> TestResult {
+    fn avro_3747_human_readable_false() -> TestResult {
         use serde::de::Deserializer as SerdeDeserializer;
 
-        assert!(crate::util::is_human_readable());
+        assert!(!crate::util::is_human_readable());
 
         let deser = &Deserializer::new(&Value::Null);
 
-        assert!(deser.is_human_readable());
+        assert!(!deser.is_human_readable());
 
         Ok(())
     }
diff --git a/avro/src/ser.rs b/avro/src/ser.rs
index 881073d..1bc9075 100644
--- a/avro/src/ser.rs
+++ b/avro/src/ser.rs
@@ -1019,13 +1019,13 @@ mod tests {
     }
 
     #[test]
-    fn avro_3747_human_readable_true() {
+    fn avro_3747_human_readable_false() {
         use serde::ser::Serializer as SerdeSerializer;
 
-        assert!(crate::util::is_human_readable());
+        assert!(!crate::util::is_human_readable());
 
         let ser = &mut Serializer {};
 
-        assert!(ser.is_human_readable());
+        assert!(!ser.is_human_readable());
     }
 }
diff --git a/avro/src/ser_schema.rs b/avro/src/ser_schema.rs
index c68aa68..7d0ed3e 100644
--- a/avro/src/ser_schema.rs
+++ b/avro/src/ser_schema.rs
@@ -2424,7 +2424,6 @@ mod tests {
         }"#,
         )?;
 
-        assert!(crate::util::is_human_readable());
         let mut buffer: Vec<u8> = Vec::new();
         let names = HashMap::new();
         let mut serializer = SchemaAwareWriteSerializer::new(&mut buffer, 
&schema, &names, None);
@@ -2446,7 +2445,7 @@ mod tests {
         }"#,
         )?;
 
-        assert!(crate::util::is_human_readable());
+        assert!(!crate::util::is_human_readable());
         let mut buffer: Vec<u8> = Vec::new();
         let names = HashMap::new();
         let mut serializer = SchemaAwareWriteSerializer::new(&mut buffer, 
&schema, &names, None);
@@ -2471,9 +2470,7 @@ mod tests {
         assert_eq!(
             buffer.as_slice(),
             &[
-                72, b'8', b'c', b'2', b'8', b'd', b'a', b'8', b'1', b'-', 
b'2', b'3', b'8', b'c',
-                b'-', b'4', b'3', b'2', b'6', b'-', b'b', b'd', b'd', b'd', 
b'-', b'4', b'e', b'3',
-                b'd', b'0', b'0', b'c', b'c', b'5', b'0', b'9', b'9'
+                32, 140, 40, 218, 129, 35, 140, 67, 38, 189, 221, 78, 61, 0, 
204, 80, 153
             ]
         );
 
@@ -2740,7 +2737,7 @@ mod tests {
             inner_record: Option<Box<TestRecord>>,
         }
 
-        assert!(crate::util::is_human_readable());
+        assert!(!crate::util::is_human_readable());
         let mut buffer: Vec<u8> = Vec::new();
         let rs = ResolvedSchema::try_from(&schema)?;
         let mut serializer =
@@ -2764,12 +2761,10 @@ mod tests {
         assert_eq!(
             buffer.as_slice(),
             &[
-                8, 116, 101, 115, 116, 20, 10, 6, 0, 195, 104, 4, 72, 56, 99, 
50, 56, 100, 97, 56,
-                49, 45, 50, 51, 56, 99, 45, 52, 51, 50, 54, 45, 98, 100, 100, 
100, 45, 52, 101, 51,
-                100, 48, 48, 99, 99, 53, 48, 57, 56, 2, 20, 105, 110, 110, 
101, 114, 95, 116, 101,
-                115, 116, 200, 1, 8, 4, 78, 70, 4, 72, 56, 99, 50, 56, 100, 
97, 56, 49, 45, 50, 51,
-                56, 99, 45, 52, 51, 50, 54, 45, 98, 100, 100, 100, 45, 52, 
101, 51, 100, 48, 48,
-                99, 99, 53, 48, 57, 57, 0
+                8, 116, 101, 115, 116, 20, 10, 6, 0, 195, 104, 4, 32, 140, 40, 
218, 129, 35, 140,
+                67, 38, 189, 221, 78, 61, 0, 204, 80, 152, 2, 20, 105, 110, 
110, 101, 114, 95, 116,
+                101, 115, 116, 200, 1, 8, 4, 78, 70, 4, 32, 140, 40, 218, 129, 
35, 140, 67, 38,
+                189, 221, 78, 61, 0, 204, 80, 153, 0
             ]
         );
 
diff --git a/avro/src/util.rs b/avro/src/util.rs
index d407474..4b89619 100644
--- a/avro/src/util.rs
+++ b/avro/src/util.rs
@@ -35,7 +35,7 @@ static MAX_ALLOCATION_BYTES: OnceLock<usize> = 
OnceLock::new();
 // crate-visible for testing
 pub(crate) static SERDE_HUMAN_READABLE: OnceLock<bool> = OnceLock::new();
 /// Whether the serializer and deserializer should indicate to types that the 
format is human-readable.
-pub const DEFAULT_SERDE_HUMAN_READABLE: bool = true;
+pub const DEFAULT_SERDE_HUMAN_READABLE: bool = false;
 
 pub trait MapHelper {
     fn string(&self, key: &str) -> Option<String>;

Reply via email to