jecsand838 commented on code in PR #8100: URL: https://github.com/apache/arrow-rs/pull/8100#discussion_r2265405842
########## arrow-avro/src/reader/mod.rs: ########## @@ -162,29 +171,42 @@ impl Decoder { /// /// Returns the number of bytes consumed. pub fn decode(&mut self, data: &[u8]) -> Result<usize, ArrowError> { - if self.expect_prefix - && data.len() >= SINGLE_OBJECT_MAGIC.len() - && !data.starts_with(&SINGLE_OBJECT_MAGIC) - { - return Err(ArrowError::ParseError( - "Expected single‑object encoding fingerprint prefix for first message \ - (writer_schema_store is set but active_fingerprint is None)" - .into(), - )); - } let mut total_consumed = 0usize; - // The loop stops when the batch is full, a schema change is staged, - // or handle_prefix indicates we need more bytes (Some(0)). while total_consumed < data.len() && self.remaining_capacity > 0 { - if let Some(n) = self.handle_prefix(&data[total_consumed..])? { - // We either consumed a prefix (n > 0) and need a schema switch, or we need - // more bytes to make a decision. Either way, this decoding attempt is finished. - total_consumed += n; + if !self.awaiting_body { + if let Some(n) = self.handle_prefix(&data[total_consumed..])? { + if n == 0 { + break; + } + total_consumed += n; + self.awaiting_body = true; + if self.remaining_capacity == self.batch_size && self.pending_schema.is_some() { + self.apply_pending_schema_if_batch_empty(); + } + if self.remaining_capacity == 0 { + break; + } + } + } + match self.active_decoder.decode(&data[total_consumed..], 1) { + Ok(n) if n > 0 => { + self.remaining_capacity -= 1; + total_consumed += n; + self.awaiting_body = false; Review Comment: There's always a magic + fingerprint prefix at the start of each single object encoded record. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org