| 662 | bool MemoryMappedFile::closed() const { return memory_map_->closed(); } |
| 663 | |
| 664 | Result<std::shared_ptr<Buffer>> MemoryMappedFile::ReadAt(int64_t position, |
| 665 | int64_t nbytes) { |
| 666 | RETURN_NOT_OK(memory_map_->CheckClosed()); |
| 667 | // if the file is writable, we acquire the lock before creating any slices |
| 668 | // in case a resize is triggered concurrently, otherwise we wouldn't detect |
| 669 | // a change in the use count |
| 670 | auto guard_resize = memory_map_->writable() |
| 671 | ? std::unique_lock<std::mutex>(memory_map_->resize_lock()) |
| 672 | : std::unique_lock<std::mutex>(); |
| 673 | |
| 674 | ARROW_ASSIGN_OR_RAISE( |
| 675 | nbytes, internal::ValidateReadRange(position, nbytes, memory_map_->size())); |
| 676 | // Arrange to page data in |
| 677 | RETURN_NOT_OK(::arrow::internal::MemoryAdviseWillNeed( |
| 678 | {{memory_map_->data() + position, static_cast<size_t>(nbytes)}})); |
| 679 | return memory_map_->Slice(position, nbytes); |
| 680 | } |
| 681 | |
| 682 | Result<int64_t> MemoryMappedFile::ReadAt(int64_t position, int64_t nbytes, void* out) { |
| 683 | RETURN_NOT_OK(memory_map_->CheckClosed()); |
no test coverage detected