martin-g commented on code in PR #339:
URL: https://github.com/apache/avro-rs/pull/339#discussion_r2553971873
##########
avro/src/encode.rs:
##########
Review Comment:
```suggestion
supported_schema: vec![SchemaKind::Bytes, SchemaKind::Fixed,
Schema::Uuid(UuidSchema::Bytes)],
```
##########
avro/src/schema.rs:
##########
@@ -111,7 +111,7 @@ pub enum Schema {
/// The underlying type is serialized and deserialized as `Schema::Bytes`
BigDecimal,
/// A universally unique identifier, annotating a string.
- Uuid,
+ Uuid(UuidSchema),
Review Comment:
This is a breaking change, so we need to use `feat!: ...` for the PR
title/commit message
##########
avro/src/ser_schema.rs:
##########
@@ -982,31 +986,30 @@ impl<'s, W: Write> SchemaAwareWriteSerializer<'s, W> {
)))
}
}
- Schema::Decimal(decimal_schema) => match
decimal_schema.inner.as_ref() {
- Schema::Bytes => self.write_bytes(value),
- Schema::Fixed(fixed_schema) => match
fixed_schema.size.checked_sub(value.len()) {
- Some(pad) => {
- let pad_val = match value.len() {
- 0 => 0,
- _ => value[0],
- };
- let padding = vec![pad_val; pad];
- self.writer
- .write(padding.as_slice())
- .map_err(Details::WriteBytes)?;
- self.writer
- .write(value)
- .map_err(|e| Details::WriteBytes(e).into())
- }
- None => Err(Details::CompareFixedSizes {
- size: fixed_schema.size,
- n: value.len(),
+ Schema::Decimal(decimal_schema) => match &decimal_schema.inner {
+ InnerDecimalSchema::Bytes => self.write_bytes(value),
+ InnerDecimalSchema::Fixed(fixed_schema) => {
+ match fixed_schema.size.checked_sub(value.len()) {
+ Some(pad) => {
+ let pad_val = match value.len() {
+ 0 => 0,
+ _ => value[0],
+ };
+ let padding = vec![pad_val; pad];
+ self.writer
+ .write(padding.as_slice())
+ .map_err(Details::WriteBytes)?;
+ self.writer
+ .write(value)
+ .map_err(|e| Details::WriteBytes(e).into())
Review Comment:
This returns only the number of bytes written in the second `.write()` call.
IMO it should add the number of the padding length too.
--
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]