martin-g commented on code in PR #491:
URL: https://github.com/apache/avro-rs/pull/491#discussion_r2871342276
##########
avro/src/serde/derive.rs:
##########
Review Comment:
```suggestion
/// and `fn get_record_fields_in_ctxt(&mut HashSet<Name>, &Namespace) ->
Option<Vec<RecordField>>` in the module provided
```
##########
avro/src/serde/ser_schema/mod.rs:
##########
@@ -373,52 +378,45 @@ impl<W: Write> ser::SerializeStruct for
SchemaAwareWriteSerializeStruct<'_, '_,
where
T: ?Sized + ser::Serialize,
{
- let record_field = self
- .record_schema
- .lookup
- .get(key)
- .and_then(|idx| self.record_schema.fields.get(*idx));
-
- match record_field {
- Some(field) => self.serialize_next_field(field, value).map_err(|e|
{
- Details::SerializeRecordFieldWithSchema {
- field_name: key.to_string(),
- record_schema: Schema::Record(self.record_schema.clone()),
- error: Box::new(e),
- }
- .into()
- }),
- None => Err(Details::FieldName(String::from(key)).into()),
+ if let Some(position) = self.record_schema.lookup.get(key).copied() {
+ let field = &self.record_schema.fields[position];
Review Comment:
Is it always safe to make this index lookup ?
The previous version uses `.get()`
##########
avro/src/schema/record/field.rs:
##########
@@ -67,38 +58,32 @@ impl Debug for RecordField {
if let Some(doc) = &self.doc {
debug.field("doc", &doc);
}
- if let Some(aliases) = &self.aliases {
- debug.field("aliases", &aliases);
+ if !self.aliases.is_empty() {
+ debug.field("aliases", &self.aliases);
}
if let Some(default) = &self.default {
debug.field("default", &default);
}
debug.field("schema", &self.schema);
- // This field is ignored as it currently has no effect
- // debug.field("order", &self.order);
- debug.field("position", &self.position);
if !self.custom_attributes.is_empty() {
debug.field("custom_attributes", &self.custom_attributes);
}
- // As we are always skipping self.order, always show the ..
- debug.finish_non_exhaustive()
+ if self.doc.is_none()
+ || !self.aliases.is_empty()
Review Comment:
```suggestion
|| self.aliases.is_empty()
```
--
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]