-
Notifications
You must be signed in to change notification settings - Fork 4.1k
GH-49904: [C++] Deprecate RandomAccessFile legacy ReadAt and ReadAsync #50061
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -151,7 +151,9 @@ RandomAccessFile::RandomAccessFile() : interface_impl_(new Impl()) {} | |||||
|
|
||||||
| Result<int64_t> RandomAccessFile::ReadAt(int64_t position, int64_t nbytes, | ||||||
| bool allow_short_read, void* out) { | ||||||
| ARROW_SUPPRESS_DEPRECATION_WARNING | ||||||
| ARROW_ASSIGN_OR_RAISE(auto real_nbytes, ReadAt(position, nbytes, out)); | ||||||
| ARROW_UNSUPPRESS_DEPRECATION_WARNING | ||||||
| if (!allow_short_read && real_nbytes != nbytes) { | ||||||
| return Status::IOError("File too short: expected to be able to read ", nbytes, | ||||||
| " bytes, got ", real_nbytes); | ||||||
|
|
@@ -167,7 +169,9 @@ Result<int64_t> RandomAccessFile::ReadAt(int64_t position, int64_t nbytes, void* | |||||
|
|
||||||
| Result<std::shared_ptr<Buffer>> RandomAccessFile::ReadAt(int64_t position, int64_t nbytes, | ||||||
| bool allow_short_read) { | ||||||
| ARROW_SUPPRESS_DEPRECATION_WARNING | ||||||
| ARROW_ASSIGN_OR_RAISE(auto buffer, ReadAt(position, nbytes)); | ||||||
| ARROW_UNSUPPRESS_DEPRECATION_WARNING | ||||||
| // XXX the internal `IoRecordedRandomAccessFile` can return a null buffer | ||||||
| if (!allow_short_read && buffer && buffer->size() != nbytes) { | ||||||
| return Status::IOError("File too short: expected to be able to read ", nbytes, | ||||||
|
|
@@ -277,7 +281,7 @@ class FileSegmentReader | |||||
| RETURN_NOT_OK(CheckOpen()); | ||||||
| int64_t bytes_to_read = std::min(nbytes, nbytes_ - position_); | ||||||
| ARROW_ASSIGN_OR_RAISE(int64_t bytes_read, | ||||||
| file_->ReadAt(file_offset_ + position_, bytes_to_read, out)); | ||||||
| file_->ReadAt(file_offset_ + position_, bytes_to_read,/*allow_short_read=*/true, out)); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same for others. |
||||||
| position_ += bytes_read; | ||||||
| return bytes_read; | ||||||
| } | ||||||
|
|
@@ -286,7 +290,7 @@ class FileSegmentReader | |||||
| RETURN_NOT_OK(CheckOpen()); | ||||||
| int64_t bytes_to_read = std::min(nbytes, nbytes_ - position_); | ||||||
| ARROW_ASSIGN_OR_RAISE(auto buffer, | ||||||
| file_->ReadAt(file_offset_ + position_, bytes_to_read)); | ||||||
| file_->ReadAt(file_offset_ + position_, bytes_to_read , /*allow_short_read=*/true)); | ||||||
| position_ += buffer->size(); | ||||||
| return buffer; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,6 @@ | |
| #include "arrow/util/macros.h" | ||
| #include "arrow/util/type_fwd.h" | ||
| #include "arrow/util/visibility.h" | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this unrelated change. |
||
| namespace arrow { | ||
| namespace io { | ||
|
|
||
|
|
@@ -295,6 +294,7 @@ class ARROW_EXPORT RandomAccessFile : public InputStream, public Seekable { | |
| /// \param[in] nbytes The number of bytes to read | ||
| /// \param[out] out The buffer to read bytes into | ||
| /// \return The number of bytes read, or an error | ||
| ARROW_DEPRECATED("Deprecated in 17.0.0. Use signature with allow_short_read instead") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be 25.0.0 if I understand correctly. |
||
| virtual Result<int64_t> ReadAt(int64_t position, int64_t nbytes, void* out); | ||
|
|
||
| /// \brief Read data from given file position. | ||
|
|
@@ -318,18 +318,21 @@ class ARROW_EXPORT RandomAccessFile : public InputStream, public Seekable { | |
| /// \param[in] position Where to read bytes from | ||
| /// \param[in] nbytes The number of bytes to read | ||
| /// \return A buffer containing the bytes read, or an error | ||
| ARROW_DEPRECATED("Deprecated in 17.0.0. Use signature with allow_short_read instead") | ||
| virtual Result<std::shared_ptr<Buffer>> ReadAt(int64_t position, int64_t nbytes); | ||
|
|
||
| /// EXPERIMENTAL: Read data asynchronously. | ||
| virtual Future<std::shared_ptr<Buffer>> ReadAsync(const IOContext&, int64_t position, | ||
| int64_t nbytes, | ||
| bool allow_short_read); | ||
| ARROW_DEPRECATED("Deprecated in 17.0.0. Use signature with allow_short_read instead") | ||
| virtual Future<std::shared_ptr<Buffer>> ReadAsync(const IOContext&, int64_t position, | ||
| int64_t nbytes); | ||
|
|
||
| /// EXPERIMENTAL: Read data asynchronously, using the file's IOContext. | ||
| Future<std::shared_ptr<Buffer>> ReadAsync(int64_t position, int64_t nbytes, | ||
| bool allow_short_read); | ||
| ARROW_DEPRECATED("Deprecated in 17.0.0. Use signature with allow_short_read instead") | ||
| Future<std::shared_ptr<Buffer>> ReadAsync(int64_t position, int64_t nbytes); | ||
|
|
||
| /// EXPERIMENTAL: Explicit multi-read. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not switching to non-deprecated equivalent?