-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++] BufferReader should zero-copy if and only if given a Buffer, not a pointer and length #37212
Comments
There's a second issue here: BufferReader has no constructor for |
So, bool BufferReader::supports_zero_copy() const { return true; } And can I try to work on this issue? |
Yeah, I think:
Feel free to take this up. Thanks! |
The ctor of Buffer has a comment implies that
Does it mean |
There's more discussion on the PR itself, FWIW |
FWIW I think there'd be a lot of value in an "examples" PR that has conventions for doing common patterns (e.g. given I own this buffer/input stream/message stream, how do I pass that ownership to the Arrow RecordBatch/Table I create?) |
Personally, I think |
@mikelui There's https://arrow.apache.org/cookbook/ / https://github.com/apache/arrow-cookbook ; more examples would always be welcome! |
### Rationale for this change Previously, when input an non-owned string, `arrow::io::BufferReader` would zero-copy it. It would cause lifetime problem. This patch add `FromString` to help build from `std::string`. ### What changes are included in this PR? * Add a ctor for FromString(std::string), and deprecate non-owning ctors ### Are these changes tested? Yes. ### Are there any user-facing changes? Some APIs are being deprecated. Users can use the new interface. * Closes: #37212 Authored-by: mwish <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
…apache#37360) ### Rationale for this change Previously, when input an non-owned string, `arrow::io::BufferReader` would zero-copy it. It would cause lifetime problem. This patch add `FromString` to help build from `std::string`. ### What changes are included in this PR? * Add a ctor for FromString(std::string), and deprecate non-owning ctors ### Are these changes tested? Yes. ### Are there any user-facing changes? Some APIs are being deprecated. Users can use the new interface. * Closes: apache#37212 Authored-by: mwish <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
…structor (#38721) ### Rationale for this change The PR [GH-37360](#37360) for issue [GH-37212](#37212) deprecated three BufferReader constructors and I noticed one of them was missing a `\deprecated` command. ### What changes are included in this PR? This adds a `\deprecated` command one of the deprecated constructors with a message. The other two didn't need it because they weren't already documented. i.e., they weren't listed under https://arrow.apache.org/docs/cpp/api/io.html so documenting them at this point just to add `\deprecated` wouldn't make sense. ### Are these changes tested? No, this is a simple docs change. ### Are there any user-facing changes? Yes, this adds a notice to the docs for this particular method. Authored-by: Bryce Mecum <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
…apache#37360) ### Rationale for this change Previously, when input an non-owned string, `arrow::io::BufferReader` would zero-copy it. It would cause lifetime problem. This patch add `FromString` to help build from `std::string`. ### What changes are included in this PR? * Add a ctor for FromString(std::string), and deprecate non-owning ctors ### Are these changes tested? Yes. ### Are there any user-facing changes? Some APIs are being deprecated. Users can use the new interface. * Closes: apache#37212 Authored-by: mwish <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
…structor (apache#38721) ### Rationale for this change The PR [apacheGH-37360](apache#37360) for issue [apacheGH-37212](apache#37212) deprecated three BufferReader constructors and I noticed one of them was missing a `\deprecated` command. ### What changes are included in this PR? This adds a `\deprecated` command one of the deprecated constructors with a message. The other two didn't need it because they weren't already documented. i.e., they weren't listed under https://arrow.apache.org/docs/cpp/api/io.html so documenting them at this point just to add `\deprecated` wouldn't make sense. ### Are these changes tested? No, this is a simple docs change. ### Are there any user-facing changes? Yes, this adds a notice to the docs for this particular method. Authored-by: Bryce Mecum <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
Describe the enhancement requested
BufferReader can be constructed from a pointer and length:
arrow/cpp/src/arrow/io/memory.cc
Lines 277 to 279 in 0e677d2
In that case, it will happily hand you a Buffer backed by that pointer:
arrow/cpp/src/arrow/io/memory.cc
Line 353 in 0e677d2
However, I don't think the APIs make it clear that this ties the lifetime of any data read from the reader to the lifetime of the input. It would be clearer if it would copy in this case, and require you to explicitly construct BufferReader from a Buffer if you want to enable zero-copy.
Component(s)
C++
The text was updated successfully, but these errors were encountered: