Kriskras99 commented on code in PR #512:
URL: https://github.com/apache/avro-rs/pull/512#discussion_r2969299749
##########
avro/src/reader/block.rs:
##########
@@ -205,6 +215,43 @@ impl<'r, R: Read> Block<'r, R> {
Ok(Some(item))
}
+ pub(super) fn read_next_deser<T: DeserializeOwned>(
+ &mut self,
+ read_schema: Option<&Schema>,
+ ) -> AvroResult<Option<T>> {
+ if self.is_empty() {
+ self.read_block_next()?;
+ if self.is_empty() {
+ return Ok(None);
+ }
+ }
+
+ let mut block_bytes = &self.buf[self.buf_idx..];
+ let b_original = block_bytes.len();
+
+ let item = if read_schema.is_some() {
+ todo!("Schema aware deserialisation does not resolve schemas yet");
+ } else {
+ let config = Config {
+ names: &self.names_refs,
+ human_readable: self.human_readable,
+ };
+ T::deserialize(SchemaAwareDeserializer::new(
+ &mut block_bytes,
+ &self.writer_schema,
+ config,
+ )?)?
+ };
+
+ if b_original != 0 && b_original == block_bytes.len() {
+ // No bytes were read, return an error to avoid an infinite loop
+ return Err(Details::ReadBlock.into());
Review Comment:
I've changed the error description from `unable to read block` to `Did not
read any bytes, block is corrupt`.
The only way that this can be triggered if the schema is `Schema::Null` and
the block actually has data.
--
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]