Skip to content

fix: Don't count map entries as written bytes when serializing a map as a record - #751

Merged
Kriskras99 merged 1 commit into
apache:mainfrom
janwaleed09:map_record_byte_count
Nov 29, 2026
Merged

Kriskras99 merged 1 commit into
apache:mainfrom
janwaleed09:map_record_byte_count

Conversation

@janwaleed09

Copy link
Copy Markdown
Contributor

SchemaAwareSerializer::serialize_map passes the number of entries as the bytes_written argument of MapOrRecordSerializer::record. So serializing a map, or a struct with #[serde(flatten)], against a record schema returns one byte too many for every entry. The written bytes are fine, only the count is off: {"a": 1, "b": 2} writes 2 bytes and returns 4. This is the same on 0.22.0 and 0.23.0.

The test uses assert_serialize, which compares the returned count with the buffer length.

#750 already includes this change as part of its refactor. I split it out because it's an independent fix and easier to follow on its own.

@Kriskras99 Kriskras99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I appreciate having this a separate PR.

@janwaleed09

Copy link
Copy Markdown
Contributor Author

Thanks for the PR!

I appreciate having this a separate PR.

Thanks for the quick review

@Kriskras99
Kriskras99 merged commit 8f96805 into apache:main Nov 29, 2026
16 checks passed
@martin-g martin-g added this to the 0.24.0 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants