westonpace commented on a change in pull request #11486: URL: https://github.com/apache/arrow/pull/11486#discussion_r740642909
########## File path: cpp/src/arrow/ipc/reader.cc ########## @@ -1358,6 +1398,62 @@ Future<std::shared_ptr<RecordBatchFileReader>> RecordBatchFileReader::OpenAsync( .Then([=]() -> Result<std::shared_ptr<RecordBatchFileReader>> { return result; }); } +Result<int64_t> IoRecordedRandomAccessFile::GetSize() { return file_size_; } + +Result<int64_t> IoRecordedRandomAccessFile::ReadAt(int64_t position, int64_t nbytes, + void* out) { + auto num_bytes_read = std::min(file_size_, position + nbytes) - position; + + if (!recorded_reads_.empty() && + position == recorded_reads_.back().offset + recorded_reads_.back().length) { + // merge continuous IOs into one if possible + recorded_reads_.back().length += num_bytes_read; + } else { + // no real IO is performed, it is only saved into a vector for replaying later + recorded_reads_.emplace_back(io::ReadRange{position, num_bytes_read}); + } + return num_bytes_read; +} Review comment: I'm not sure if it matters or not but I think read calls should advance the position. For example: ``` Read(10) // Reads bytes 0-9 Read(10) // Reads bytes 10-19 ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org