You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Kriskras99 (via GitHub)" <gi...@apache.org> on 2025/11/12 13:05:39 UTC

[PR] Small fixes [avro-rs]

Kriskras99 opened a new pull request, #336:
URL: https://github.com/apache/avro-rs/pull/336

   These are some small things I ran into when working on async support.


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2522016361


##########
avro/src/util.rs:
##########


Review Comment:
   Yes, you're right.



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2523971178


##########
avro/src/schema_equality.rs:
##########


Review Comment:
   You're totally right, added!



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g merged PR #336:
URL: https://github.com/apache/avro-rs/pull/336


-- 
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: dev-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2518442737


##########
avro/src/util.rs:
##########


Review Comment:
   Do we need to do something like `i = u64::from_le(i)` here too ?
   On a big endian machine the number will be wrong now, no ?



##########
avro/src/util.rs:
##########
@@ -100,7 +100,8 @@ pub(crate) fn zag_i64<R: Read>(reader: &mut R) -> AvroResult<i64> {
     })
 }
 
-fn encode_variable<W: Write>(mut z: u64, mut writer: W) -> AvroResult<usize> {
+fn encode_variable<W: Write>(n: i64, mut writer: W) -> AvroResult<usize> {
+    let mut z = (((n << 1) ^ (n >> 63)) as u64).to_le();

Review Comment:
   This is to be complaint with `a double is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to Java’s [doubleToRawLongBits](https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#doubleToRawLongBits-double-) and then encoded in little-endian format.` from the [specification](https://avro.apache.org/docs/1.12.0/specification/#binary-encoding), right ?



##########
avro/src/schema_equality.rs:
##########
@@ -54,160 +54,120 @@ pub struct StructFieldEq {
 }
 
 impl SchemataEq for StructFieldEq {
+    #[rustfmt::skip]
     fn compare(&self, schema_one: &Schema, schema_two: &Schema) -> bool {
-        macro_rules! compare_primitive {
-            ($primitive:ident) => {
-                if let Schema::$primitive = schema_one {
-                    if let Schema::$primitive = schema_two {
-                        return true;
-                    }
-                    return false;
-                }
-            };
-        }
-
         if schema_one.name() != schema_two.name() {
             return false;
         }
 
-        compare_primitive!(Null);
-        compare_primitive!(Boolean);
-        compare_primitive!(Int);
-        compare_primitive!(Int);
-        compare_primitive!(Long);
-        compare_primitive!(Float);
-        compare_primitive!(Double);
-        compare_primitive!(Bytes);
-        compare_primitive!(String);
-        compare_primitive!(Uuid);
-        compare_primitive!(BigDecimal);
-        compare_primitive!(Date);
-        compare_primitive!(Duration);
-        compare_primitive!(TimeMicros);
-        compare_primitive!(TimeMillis);
-        compare_primitive!(TimestampMicros);
-        compare_primitive!(TimestampMillis);
-        compare_primitive!(TimestampNanos);
-        compare_primitive!(LocalTimestampMicros);
-        compare_primitive!(LocalTimestampMillis);
-        compare_primitive!(LocalTimestampNanos);
-
         if self.include_attributes
             && schema_one.custom_attributes() != schema_two.custom_attributes()
         {
             return false;
         }
 
-        if let Schema::Record(RecordSchema {
-            fields: fields_one, ..
-        }) = schema_one
-        {
-            if let Schema::Record(RecordSchema {
-                fields: fields_two, ..
-            }) = schema_two
-            {
-                return self.compare_fields(fields_one, fields_two);
+        match (schema_one, schema_two) {
+            (Schema::Null, Schema::Null) => true,
+            (Schema::Null, _) => false,
+            (Schema::Boolean, Schema::Boolean) => true,
+            (Schema::Boolean, _) => false,
+            (Schema::Int, Schema::Int) => true,
+            (Schema::Int, _) => false,
+            (Schema::Long, Schema::Long) => true,
+            (Schema::Long, _) => false,
+            (Schema::Float, Schema::Float) => true,
+            (Schema::Float, _) => false,
+            (Schema::Double, Schema::Double) => true,
+            (Schema::Double, _) => false,
+            (Schema::Bytes, Schema::Bytes) => true,
+            (Schema::Bytes, _) => false,
+            (Schema::String, Schema::String) => true,
+            (Schema::String, _) => false,
+            (Schema::Uuid, Schema::Uuid) => true,
+            (Schema::Uuid, _) => false,
+            (Schema::BigDecimal, Schema::BigDecimal) => true,
+            (Schema::BigDecimal, _) => false,
+            (Schema::Date, Schema::Date) => true,
+            (Schema::Date, _) => false,
+            (Schema::Duration, Schema::Duration) => true,
+            (Schema::Duration, _) => false,
+            (Schema::TimeMicros, Schema::TimeMicros) => true,
+            (Schema::TimeMicros, _) => false,
+            (Schema::TimeMillis, Schema::TimeMillis) => true,
+            (Schema::TimeMillis, _) => false,
+            (Schema::TimestampMicros, Schema::TimestampMicros) => true,
+            (Schema::TimestampMicros, _) => false,
+            (Schema::TimestampMillis, Schema::TimestampMillis) => true,
+            (Schema::TimestampMillis, _) => false,
+            (Schema::TimestampNanos, Schema::TimestampNanos) => true,
+            (Schema::TimestampNanos, _) => false,
+            (Schema::LocalTimestampMicros, Schema::LocalTimestampMicros) => true,
+            (Schema::LocalTimestampMicros, _) => false,
+            (Schema::LocalTimestampMillis, Schema::LocalTimestampMillis) => true,
+            (Schema::LocalTimestampMillis, _) => false,
+            (Schema::LocalTimestampNanos, Schema::LocalTimestampNanos) => true,
+            (Schema::LocalTimestampNanos, _) => false,
+            (
+                Schema::Record(RecordSchema { fields: fields_one, ..}),
+                Schema::Record(RecordSchema { fields: fields_two, ..})
+            ) => {
+                self.compare_fields(fields_one, fields_two)
             }
-            return false;
-        }
-
-        if let Schema::Enum(EnumSchema {
-            symbols: symbols_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Enum(EnumSchema {
-                symbols: symbols_two,
-                ..
-            }) = schema_two
-            {
-                return symbols_one == symbols_two;
+            (Schema::Record(_), _) => false,
+            (
+                Schema::Enum(EnumSchema { symbols: symbols_one, ..}),
+                Schema::Enum(EnumSchema { symbols: symbols_two, .. })
+            ) => {
+                symbols_one == symbols_two
             }
-            return false;
-        }
-
-        if let Schema::Fixed(FixedSchema { size: size_one, .. }) = schema_one {
-            if let Schema::Fixed(FixedSchema { size: size_two, .. }) = schema_two {
-                return size_one == size_two;
+            (Schema::Enum(_), _) => false,
+            (
+                Schema::Fixed(FixedSchema { size: size_one, ..}),
+                Schema::Fixed(FixedSchema { size: size_two, .. })
+            ) => {
+                size_one == size_two
             }
-            return false;
-        }
-
-        if let Schema::Union(UnionSchema {
-            schemas: schemas_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Union(UnionSchema {
-                schemas: schemas_two,
-                ..
-            }) = schema_two
-            {
-                return schemas_one.len() == schemas_two.len()
+            (Schema::Fixed(_), _) => false,
+            (
+                Schema::Union(UnionSchema { schemas: schemas_one, ..}),
+                Schema::Union(UnionSchema { schemas: schemas_two, .. })
+            ) => {
+                schemas_one.len() == schemas_two.len()
                     && schemas_one
-                        .iter()
-                        .zip(schemas_two.iter())
-                        .all(|(s1, s2)| self.compare(s1, s2));
+                    .iter()
+                    .zip(schemas_two.iter())
+                    .all(|(s1, s2)| self.compare(s1, s2))
             }
-            return false;
-        }
-
-        if let Schema::Decimal(DecimalSchema {
-            precision: precision_one,
-            scale: scale_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Decimal(DecimalSchema {
-                precision: precision_two,
-                scale: scale_two,
-                ..
-            }) = schema_two
-            {
-                return precision_one == precision_two && scale_one == scale_two;
+            (Schema::Union(_), _) => false,
+            (
+                Schema::Decimal(DecimalSchema { precision: precision_one, scale: scale_one, ..}),
+                Schema::Decimal(DecimalSchema { precision: precision_two, scale: scale_two, .. })
+            ) => {
+                precision_one == precision_two && scale_one == scale_two
             }
-            return false;
-        }
-
-        if let Schema::Array(ArraySchema {
-            items: items_one, ..
-        }) = schema_one
-        {
-            if let Schema::Array(ArraySchema {
-                items: items_two, ..
-            }) = schema_two
-            {
-                return items_one == items_two;
+            (Schema::Decimal(_), _) => false,
+            (
+                Schema::Array(ArraySchema { items: items_one, ..}),
+                Schema::Array(ArraySchema { items: items_two, ..})
+            ) => {
+                items_one == items_two

Review Comment:
   ```suggestion
                   self.compare(items_one, items_two)
   ```



##########
avro/src/schema_equality.rs:
##########


Review Comment:
   ```suggestion
                   .all(|(f1, f2)| f1.name == f2.name && self.compare(&f1.schema, &f2.schema))
   ```



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2524833092


##########
avro/src/util.rs:
##########
@@ -100,25 +105,34 @@ pub(crate) fn zag_i64<R: Read>(reader: &mut R) -> AvroResult<i64> {
     })
 }
 
-fn encode_variable<W: Write>(mut z: u64, mut writer: W) -> AvroResult<usize> {
+/// Write the number as a varint to the writer.
+///
+/// Note: this function does not do zigzag encoding, for that see [`zig_i32`] and [`zig_i64`].
+fn encode_variable<W: Write>(mut zigzagged: u64, mut writer: W) -> AvroResult<usize> {
+    // Ensure the number is little endian for the varint encoding (no-op on LE systems)
+    zigzagged = zigzagged.to_le();

Review Comment:
   I don't think this is correct. Encoding a varint on BE and then decoding that on LE should give the same result (but the specification doesn't actually specify which endianness to use).



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2522012479


##########
avro/src/util.rs:
##########
@@ -100,7 +100,8 @@ pub(crate) fn zag_i64<R: Read>(reader: &mut R) -> AvroResult<i64> {
     })
 }
 
-fn encode_variable<W: Write>(mut z: u64, mut writer: W) -> AvroResult<usize> {
+fn encode_variable<W: Write>(n: i64, mut writer: W) -> AvroResult<usize> {
+    let mut z = (((n << 1) ^ (n >> 63)) as u64).to_le();

Review Comment:
   No, `encode_variable` is purely used for zigzag encoding `int` and `long` types.
   The bit twiddling is to do the zigzag, while the remainder of the function is for doing the varint encoding.
   I've moved the bit twiddling back to `zig_i64`, and documented why they are two different functions



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2522034010


##########
avro/src/schema_equality.rs:
##########
@@ -54,160 +54,120 @@ pub struct StructFieldEq {
 }
 
 impl SchemataEq for StructFieldEq {
+    #[rustfmt::skip]
     fn compare(&self, schema_one: &Schema, schema_two: &Schema) -> bool {
-        macro_rules! compare_primitive {
-            ($primitive:ident) => {
-                if let Schema::$primitive = schema_one {
-                    if let Schema::$primitive = schema_two {
-                        return true;
-                    }
-                    return false;
-                }
-            };
-        }
-
         if schema_one.name() != schema_two.name() {
             return false;
         }
 
-        compare_primitive!(Null);
-        compare_primitive!(Boolean);
-        compare_primitive!(Int);
-        compare_primitive!(Int);
-        compare_primitive!(Long);
-        compare_primitive!(Float);
-        compare_primitive!(Double);
-        compare_primitive!(Bytes);
-        compare_primitive!(String);
-        compare_primitive!(Uuid);
-        compare_primitive!(BigDecimal);
-        compare_primitive!(Date);
-        compare_primitive!(Duration);
-        compare_primitive!(TimeMicros);
-        compare_primitive!(TimeMillis);
-        compare_primitive!(TimestampMicros);
-        compare_primitive!(TimestampMillis);
-        compare_primitive!(TimestampNanos);
-        compare_primitive!(LocalTimestampMicros);
-        compare_primitive!(LocalTimestampMillis);
-        compare_primitive!(LocalTimestampNanos);
-
         if self.include_attributes
             && schema_one.custom_attributes() != schema_two.custom_attributes()
         {
             return false;
         }
 
-        if let Schema::Record(RecordSchema {
-            fields: fields_one, ..
-        }) = schema_one
-        {
-            if let Schema::Record(RecordSchema {
-                fields: fields_two, ..
-            }) = schema_two
-            {
-                return self.compare_fields(fields_one, fields_two);
+        match (schema_one, schema_two) {
+            (Schema::Null, Schema::Null) => true,
+            (Schema::Null, _) => false,
+            (Schema::Boolean, Schema::Boolean) => true,
+            (Schema::Boolean, _) => false,
+            (Schema::Int, Schema::Int) => true,
+            (Schema::Int, _) => false,
+            (Schema::Long, Schema::Long) => true,
+            (Schema::Long, _) => false,
+            (Schema::Float, Schema::Float) => true,
+            (Schema::Float, _) => false,
+            (Schema::Double, Schema::Double) => true,
+            (Schema::Double, _) => false,
+            (Schema::Bytes, Schema::Bytes) => true,
+            (Schema::Bytes, _) => false,
+            (Schema::String, Schema::String) => true,
+            (Schema::String, _) => false,
+            (Schema::Uuid, Schema::Uuid) => true,
+            (Schema::Uuid, _) => false,
+            (Schema::BigDecimal, Schema::BigDecimal) => true,
+            (Schema::BigDecimal, _) => false,
+            (Schema::Date, Schema::Date) => true,
+            (Schema::Date, _) => false,
+            (Schema::Duration, Schema::Duration) => true,
+            (Schema::Duration, _) => false,
+            (Schema::TimeMicros, Schema::TimeMicros) => true,
+            (Schema::TimeMicros, _) => false,
+            (Schema::TimeMillis, Schema::TimeMillis) => true,
+            (Schema::TimeMillis, _) => false,
+            (Schema::TimestampMicros, Schema::TimestampMicros) => true,
+            (Schema::TimestampMicros, _) => false,
+            (Schema::TimestampMillis, Schema::TimestampMillis) => true,
+            (Schema::TimestampMillis, _) => false,
+            (Schema::TimestampNanos, Schema::TimestampNanos) => true,
+            (Schema::TimestampNanos, _) => false,
+            (Schema::LocalTimestampMicros, Schema::LocalTimestampMicros) => true,
+            (Schema::LocalTimestampMicros, _) => false,
+            (Schema::LocalTimestampMillis, Schema::LocalTimestampMillis) => true,
+            (Schema::LocalTimestampMillis, _) => false,
+            (Schema::LocalTimestampNanos, Schema::LocalTimestampNanos) => true,
+            (Schema::LocalTimestampNanos, _) => false,
+            (
+                Schema::Record(RecordSchema { fields: fields_one, ..}),
+                Schema::Record(RecordSchema { fields: fields_two, ..})
+            ) => {
+                self.compare_fields(fields_one, fields_two)
             }
-            return false;
-        }
-
-        if let Schema::Enum(EnumSchema {
-            symbols: symbols_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Enum(EnumSchema {
-                symbols: symbols_two,
-                ..
-            }) = schema_two
-            {
-                return symbols_one == symbols_two;
+            (Schema::Record(_), _) => false,
+            (
+                Schema::Enum(EnumSchema { symbols: symbols_one, ..}),
+                Schema::Enum(EnumSchema { symbols: symbols_two, .. })
+            ) => {
+                symbols_one == symbols_two
             }
-            return false;
-        }
-
-        if let Schema::Fixed(FixedSchema { size: size_one, .. }) = schema_one {
-            if let Schema::Fixed(FixedSchema { size: size_two, .. }) = schema_two {
-                return size_one == size_two;
+            (Schema::Enum(_), _) => false,
+            (
+                Schema::Fixed(FixedSchema { size: size_one, ..}),
+                Schema::Fixed(FixedSchema { size: size_two, .. })
+            ) => {
+                size_one == size_two
             }
-            return false;
-        }
-
-        if let Schema::Union(UnionSchema {
-            schemas: schemas_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Union(UnionSchema {
-                schemas: schemas_two,
-                ..
-            }) = schema_two
-            {
-                return schemas_one.len() == schemas_two.len()
+            (Schema::Fixed(_), _) => false,
+            (
+                Schema::Union(UnionSchema { schemas: schemas_one, ..}),
+                Schema::Union(UnionSchema { schemas: schemas_two, .. })
+            ) => {
+                schemas_one.len() == schemas_two.len()
                     && schemas_one
-                        .iter()
-                        .zip(schemas_two.iter())
-                        .all(|(s1, s2)| self.compare(s1, s2));
+                    .iter()
+                    .zip(schemas_two.iter())
+                    .all(|(s1, s2)| self.compare(s1, s2))
             }
-            return false;
-        }
-
-        if let Schema::Decimal(DecimalSchema {
-            precision: precision_one,
-            scale: scale_one,
-            ..
-        }) = schema_one
-        {
-            if let Schema::Decimal(DecimalSchema {
-                precision: precision_two,
-                scale: scale_two,
-                ..
-            }) = schema_two
-            {
-                return precision_one == precision_two && scale_one == scale_two;
+            (Schema::Union(_), _) => false,
+            (
+                Schema::Decimal(DecimalSchema { precision: precision_one, scale: scale_one, ..}),
+                Schema::Decimal(DecimalSchema { precision: precision_two, scale: scale_two, .. })
+            ) => {
+                precision_one == precision_two && scale_one == scale_two

Review Comment:
   I think so too, as a `Decimal(Bytes)` and `Decimal(Fixed)` are not compatible



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2522652486


##########
avro/src/schema_equality.rs:
##########


Review Comment:
   RecordField::name != Schema::name



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Kriskras99 (via GitHub)" <gi...@apache.org>.
Kriskras99 commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2522024590


##########
avro/src/schema_equality.rs:
##########


Review Comment:
   The first thing `self.compare` does is checking the name, so I think this optimization is unnecessary (it saves on a function call, but the function is in L1 cache so the impact should be minimal)



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Small fixes [avro-rs]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #336:
URL: https://github.com/apache/avro-rs/pull/336#discussion_r2524819722


##########
avro/src/util.rs:
##########
@@ -100,25 +105,34 @@ pub(crate) fn zag_i64<R: Read>(reader: &mut R) -> AvroResult<i64> {
     })
 }
 
-fn encode_variable<W: Write>(mut z: u64, mut writer: W) -> AvroResult<usize> {
+/// Write the number as a varint to the writer.
+///
+/// Note: this function does not do zigzag encoding, for that see [`zig_i32`] and [`zig_i64`].
+fn encode_variable<W: Write>(mut zigzagged: u64, mut writer: W) -> AvroResult<usize> {
+    // Ensure the number is little endian for the varint encoding (no-op on LE systems)
+    zigzagged = zigzagged.to_le();

Review Comment:
   The addition of `to_le()` here is incorrect and will break varint encoding on big-endian systems. 
   
   Varint encoding is endian-independent - it encodes numbers by extracting 7-bit chunks from least to most significant, which works correctly regardless of the system's endianness. The original code was correct.
   
   On a big-endian system, calling `to_le()` would byte-swap the value before encoding, producing incorrect output. On little-endian systems, it's a no-op but adds unnecessary operations.
   
   **Recommendation:** Remove the `to_le()` call and the associated comment on line 112.
   ```suggestion
   
   ```



##########
avro/src/util.rs:
##########
@@ -140,7 +154,7 @@ fn decode_variable<R: Read>(reader: &mut R) -> AvroResult<u64> {
         }
     }
 
-    Ok(i)
+    Ok(u64::from_le(i))

Review Comment:
   The addition of `from_le()` here is incorrect and will break varint decoding on big-endian systems.
   
   The varint decoding algorithm already correctly reconstructs the value by shifting and ORing 7-bit chunks, which is endian-independent. Calling `from_le()` assumes the result is in little-endian format, which it isn't - it's just the correctly reconstructed value.
   
   On a big-endian system, this would byte-swap the correctly decoded value, producing incorrect results. On little-endian systems, it's a no-op but adds unnecessary operations.
   
   **Recommendation:** Remove the `from_le()` call and keep it as `Ok(i)`.
   ```suggestion
       Ok(i)
   ```



-- 
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: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org