V0ldek opened a new pull request, #6132:
URL: https://github.com/apache/arrow-rs/pull/6132
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
Closes #6099.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
Current writer API automatically wraps the supplied `std::io::Writer` impl
into a `BufWriter`.
It is cleaner and more idiomatic to have the default be using the supplied
impl directly, as the user might already have a `BufWriter` or an impl that
doesn't actually benefit from buffering at all.
StreamReader does a similar thing, but it also exposes a
`try_new_unbuffered` that bypasses the internal wrap. These APIs are
incosistent between reader/writer and also between `Stream` and `File`
versions, but there's no strong reason for that.
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
Here we propose a consistent and non-buffered by default API:
- `try_new` does not wrap the passed reader/writer,
- `try_new_buffered` is a convenience function that does wrap the
reader/writer into a BufReader/BufWriter,
- all four publicly exposed IPC reader/writers follow the above
consistently, i.e. `StreamReader`, `FileReader`, `StreamWriter`, `FileWriter`.
An additional tweak: removed the generic type bounds from struct definitions
on the four types, as that is the idiomatic Rust approach (see e.g. stdlib's
`HashMap` that has no bounds on the struct definition, only the impl requires
`Hash + Eq`).
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking
change` label.
-->
- [BREAKING] function
`arrow_ipc::reader::StreamReader<R>::try_new_unbuffered` is removed;
- [BREAKING] function
`arrow_ipc::reader::StreamReader<std::io::BufReader<R>>::try_new` is renamed to
`try_new_buffered`;
- function
`arrow_ipc::reader::FileReader<std::io:::BufReader<R>>::try_new_buffered` is
added;
- function
`arrow_ipc::writer::StreamWriter<std::io::BufWriter<W>>::try_new_buffered` is
added;
- function
`arrow_ipc::writer::FileWriter<std::io::BufWriter<W>>::try_new_buffered` is
added.
The fact that `try_new` is now unbuffered is a silent change from the API
perspective. A number of rustdocs explicitly referenced the internal buffering
and have been reworded accordingly.
--
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]