Skip to content

feat: Add get_ref and get_mut methods to Writer - #201

Merged
martin-g merged 3 commits into
apache:mainfrom
Kriskras99:feat/writer_peek
May 29, 2025
Merged

martin-g merged 3 commits into
apache:mainfrom
Kriskras99:feat/writer_peek

Conversation

@Kriskras99

@Kriskras99 Kriskras99 commented May 27, 2025 •

Copy link
Copy Markdown
Contributor

This can be useful for checking the size of the output. For example, you might want to batch values every N megabytes.

I've also added two commits, one which simplifies the doc comments and one which makes the WriterBuilder type public.

The alternative to peek_inner is doing:

  • let aw = Writer::builder().schema(schema).marker(marker).writer(writer)
  • aw.append_ser(value)
  • writer = aw.into_inner()
  • writer.len()
  • aw = Writer::append_to(schema, writer, marker)
    And this recreates the writer every time, which does a bunch of allocations.

Comment thread avro/src/writer.rs Resolved
This can be useful for checking the size of the output. For example,
you might want to batch values every N megabytes.
@Kriskras99 Kriskras99 changed the title feat: Add peek_inner method to Writer feat: Add get_ref and get_mut methods to Writer May 29, 2025
@martin-g
martin-g merged commit 0f23dda into apache:main May 29, 2025
@martin-g

Copy link
Copy Markdown
Member

Thank you, @Kriskras99 !

martin-g pushed a commit to Kriskras99/avro-rs that referenced this pull request May 30, 2025
* feat: Add `get_ref` and `get_mut` methods to `Writer`

This can be useful for checking the size of the output. For example,
you might want to batch values every N megabytes.

* chore: simplify doc comments and add a colon after every `NOTE`

* fix: document `WriterBuilder`
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