Repository navigation
feat!: Rework SpecificSingleObjectWriter - #445
Merged
Merged
Conversation
`ResolvedOwnedSchema` now uses a self-referential struct when resolving the schema, so it does not need to clone all named schemas contained in it. This also fixes a bug in `reader::Block::read_writer_schema` where it unnecessarily parses the schemata twice.
It now resolves the schema and caches it. It also no longer uses `GenericSingleObjectWriter` for the header and does it directly. This removes the need for a buffer. This is a breaking change: - `SpecificSingleObjectWriter::with_capcity` has been removed. - `write_avro_datum_ref` now also takes a `names: &NamesRef` argument
martin-g
approved these changes
Jan 27, 2026
| .write_all(&self.header) | ||
| .map_err(Details::WriteBytes)?; | ||
| let value: Value = data.into(); | ||
| let bytes = write_value_ref_owned_resolved(&self.resolved, &value, writer)?; |
Member
There was a problem hiding this comment.
If this fails then the writer will contain the already written header.
How about something like:
let mut buffer = Vec::new();
let bytes = write_value_ref_owned_resolved(&self.resolved, &value, &mut buffer)?;
writer.write_all(&self.header).map_err(Details::WriteBytes)?;
writer.write_all(&buffer).map_err(Details::WriteBytes)?;
Ok(bytes + self.header.len())
Contributor
Author
There was a problem hiding this comment.
writer.write_all(&buffer) can also fail partway through.
I don't think this is worth the performance penalty.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first commit changes
ResolvedSchemaandResolvedOwnedSchemato use the same logic for resolving.ResolvedOwnedSchemanow also uses a self-referential struct when resolving the schema, so it does not need to clone all named schemas contained in it.The second commit contains the rework of
SpecificSingleObjectWriterIt now resolves the schema and caches it. It also no longer uses
GenericSingleObjectWriterfor the header and does it directly. This removes the need for a buffer.This is a breaking change:
SpecificSingleObjectWriter::with_capcityhas been removed.write_avro_datum_refnow also takes anames: &NamesRefargumentThis also fixes a bug in
reader::Block::read_writer_schemawhere it unnecessarily parses the schemata twice.Closes #439