MCPcopy Create free account
hub / github.com/apache/arrow / ReadAt

Method ReadAt

cpp/src/arrow/io/file.cc:664–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662bool MemoryMappedFile::closed() const { return memory_map_->closed(); }
663
664Result<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
682Result<int64_t> MemoryMappedFile::ReadAt(int64_t position, int64_t nbytes, void* out) {
683 RETURN_NOT_OK(memory_map_->CheckClosed());

Callers 1

DoReadAtMethod · 0.45

Calls 8

ValidateReadRangeFunction · 0.85
MemoryAdviseWillNeedFunction · 0.85
writableMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.50
CheckClosedMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected