jordepic commented on code in PR #10713:
URL: https://github.com/apache/arrow-rs/pull/10713#discussion_r3833317066
##########
arrow-avro/src/reader/mod.rs:
##########
@@ -736,6 +741,31 @@ impl Decoder {
Ok(total_consumed)
}
+ /// Decode exactly one unframed Avro datum with the active writer schema.
+ ///
+ /// This is intended for transports such as Kafka where the message
boundary is external to
+ /// Avro. It returns the number of datum bytes consumed, allowing the
caller to ignore transport
+ /// payload bytes after the first datum when its format contract requires
that behavior.
+ /// Consecutive unframed datums can be decoded by repeatedly passing the
unconsumed suffix.
+ /// If the current batch is full, this method returns `Ok(0)` until
[`Self::flush`] is called.
+ ///
+ /// The decoder must already have the desired active fingerprint, and this
method does not
+ /// inspect or switch framing fingerprints.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error if the datum is incomplete, malformed, or
incompatible with the active
+ /// writer schema.
+ pub fn decode_datum(&mut self, data: &[u8]) -> Result<usize, AvroError> {
+ if self.remaining_capacity == 0 {
+ return Ok(0);
+ }
+ let consumed = self.active_decoder.decode(data, 1)?;
+ self.remaining_capacity -= 1;
+ self.awaiting_body = false;
+ Ok(consumed)
+ }
Review Comment:
good suggestion!
--
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]