lidavidm commented on code in PR #49897:
URL: https://github.com/apache/arrow/pull/49897#discussion_r3166534669
##########
cpp/src/arrow/io/interfaces.cc:
##########
@@ -149,38 +149,73 @@ RandomAccessFile::~RandomAccessFile() = default;
RandomAccessFile::RandomAccessFile() : interface_impl_(new Impl()) {}
+Result<int64_t> RandomAccessFile::ReadAt(int64_t position, int64_t nbytes,
+ bool allow_short_read, void* out) {
+ ARROW_ASSIGN_OR_RAISE(auto real_nbytes, ReadAt(position, nbytes, out));
+ if (!allow_short_read && real_nbytes != nbytes) {
+ return Status::IOError("File too short: expected to be able to read ",
nbytes,
+ " bytes, got ", real_nbytes);
+ }
+ return real_nbytes;
+}
+
Result<int64_t> RandomAccessFile::ReadAt(int64_t position, int64_t nbytes,
void* out) {
std::lock_guard<std::mutex> lock(interface_impl_->lock_);
RETURN_NOT_OK(Seek(position));
return Read(nbytes, out);
}
+Result<std::shared_ptr<Buffer>> RandomAccessFile::ReadAt(int64_t position,
int64_t nbytes,
+ bool
allow_short_read) {
+ ARROW_ASSIGN_OR_RAISE(auto buffer, ReadAt(position, nbytes));
+ // 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,
+ " bytes, got ", buffer->size());
+ }
Review Comment:
Ah that's right, it's the implementation that doesn't actually do
anything...I suppose ideally we'd refactor to avoid the need for this in the
first place but in the meantime we have no choice here then.
--
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]