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

Method ReadAt

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

Source from the content-addressed store, hash-verified

670bool MemoryMappedFile::closed() const { return memory_map_->closed(); }
671
672Result<std::shared_ptr<Buffer>> MemoryMappedFile::ReadAt(int64_t position,
673 int64_t nbytes) {
674 RETURN_NOT_OK(memory_map_->CheckClosed());
675 // if the file is writable, we acquire the lock before creating any slices
676 // in case a resize is triggered concurrently, otherwise we wouldn't detect
677 // a change in the use count
678 auto guard_resize = memory_map_->writable()
679 ? std::unique_lock<std::mutex>(memory_map_->resize_lock())
680 : std::unique_lock<std::mutex>();
681
682 ARROW_ASSIGN_OR_RAISE(
683 nbytes, internal::ValidateReadRange(position, nbytes, memory_map_->size()));
684 // Arrange to page data in
685 RETURN_NOT_OK(::arrow::internal::MemoryAdviseWillNeed(
686 {{memory_map_->data() + position, static_cast<size_t>(nbytes)}}));
687 return memory_map_->Slice(position, nbytes);
688}
689
690Result<int64_t> MemoryMappedFile::ReadAt(int64_t position, int64_t nbytes, void* out) {
691 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