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

Method ReadAt

cpp/src/arrow/io/hdfs.cc:138–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 bool closed() const { return !is_open_; }
137
138 Result<int64_t> ReadAt(int64_t position, int64_t nbytes, uint8_t* buffer) {
139 RETURN_NOT_OK(CheckClosed());
140 if (!driver_->HasPread()) {
141 std::lock_guard<std::mutex> guard(lock_);
142 RETURN_NOT_OK(Seek(position));
143 return Read(nbytes, buffer);
144 }
145
146 constexpr int64_t kMaxBlockSize = std::numeric_limits<int32_t>::max();
147 int64_t total_bytes = 0;
148 while (nbytes > 0) {
149 const auto block_size = static_cast<tSize>(std::min(kMaxBlockSize, nbytes));
150 tSize ret =
151 driver_->Pread(fs_, file_, static_cast<tOffset>(position), buffer, block_size);
152 CHECK_FAILURE(ret, "read");
153 DCHECK_LE(ret, block_size);
154 if (ret == 0) {
155 break; // EOF
156 }
157 buffer += ret;
158 total_bytes += ret;
159 position += ret;
160 nbytes -= ret;
161 }
162 return total_bytes;
163 }
164
165 Result<std::shared_ptr<Buffer>> ReadAt(int64_t position, int64_t nbytes) {
166 RETURN_NOT_OK(CheckClosed());

Callers

nothing calls this directly

Calls 5

HasPreadMethod · 0.80
PreadMethod · 0.80
CheckClosedFunction · 0.70
ReadFunction · 0.70
ResizeMethod · 0.45

Tested by

no test coverage detected