You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: Clarify intended usage of SpecificSingleObjectWriter and header_written flag #431
I'm using SpecificSingleObjectWriter for Avro single object encoding and noticed an inconsistency in behavior between SpecificSingleObjectWriter::write_ref() and GenericSingleObjectWriter::write_value_ref().
Current Behavior
GenericSingleObjectWriter::write_value_ref() always writes the header on every call:
pubfnwrite_value_ref<W:Write>(&mutself,v:&Value,writer:&mutW) -> AvroResult<usize>{let original_length = self.buffer.len();// header is pre-stored in buffer// ...write_value_ref_owned_resolved(&self.resolved, v,&mutself.buffer)?;
writer.write_all(&self.buffer)?;// writes header + dataself.buffer.truncate(original_length);// resets to just headerOk(len)}
However, SpecificSingleObjectWriter has a header_written: bool field and previously only wrote the header on the first call to write_ref():
pubfnwrite_ref<W:Write>(&mutself,data:&T,writer:&mutW) -> AvroResult<usize>{if !self.header_written{
bytes_written += writer.write(self.inner.buffer.as_slice())?;self.header_written = true;}// ... serialize data without header on subsequent calls}
Questions
What is the intended use case for header_written?
Is SpecificSingleObjectWriter meant for streaming multiple records after a single header (like the object container format)?
Or is it meant for single-object encoding where each message should be independently decodable (requiring header on each message)?
Why the inconsistency with GenericSingleObjectWriter?
GenericSingleObjectWriter::write_value_ref() writes header every time
SpecificSingleObjectWriter::write_ref() only wrote header once
Current State
I've modified write_ref() to always write the header (matching GenericSingleObjectWriter behavior) and removed the header_written field. This allows reusing one writer for multiple independent messages without the cost of reconstructing the writer each time.
This is kind of a band aid for - this issue is just for clarification.
This was introduced in #139, and I think it might have been an accidental change.
I've asked the original author of the change, and @martin-g might also know more.
Activity
Kriskras99 commentedon Jan 23, 2026
This was introduced in #139, and I think it might have been an accidental change.
I've asked the original author of the change, and @martin-g might also know more.
martin-g commentedon Jan 23, 2026
Looks like a bug to me.
flxo commentedon Jan 24, 2026
Thanks for clarification! I will open a PR on Monday.