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

Method ReadBuffer

cpp/src/arrow/ipc/reader.cc:195–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 max_recursion_depth_(options.max_recursion_depth) {}
194
195 Status ReadBuffer(int64_t offset, int64_t length, std::shared_ptr<Buffer>* out) {
196 // This construct permits overriding GetBuffer at compile time
197 if (skip_io_) {
198 return Status::OK();
199 }
200 if (offset < 0) {
201 return Status::Invalid("Negative offset for reading buffer ", buffer_index_);
202 }
203 if (length < 0) {
204 return Status::Invalid("Negative length for reading buffer ", buffer_index_);
205 }
206 auto read_end = AddWithOverflow({offset, length});
207 if (!read_end.has_value() || (file_length_.has_value() && read_end > file_length_)) {
208 return Status::Invalid("Buffer ", buffer_index_, " exceeds IPC file area");
209 }
210 if (!bit_util::IsMultipleOf8(offset)) {
211 return Status::Invalid("Buffer ", buffer_index_,
212 " did not start on 8-byte aligned offset: ", offset);
213 }
214 if (file_) {
215 return file_->ReadAt(offset, length, /*allow_short_read=*/false).Value(out);
216 } else {
217 if (!AddWithOverflow({read_end.value(), file_offset_}).has_value()) {
218 return Status::Invalid("Buffer ", buffer_index_, " exceeds IPC file area");
219 }
220 read_request_.RequestRange(offset + file_offset_, length, out);
221 return Status::OK();
222 }
223 }
224
225 Status LoadType(const DataType& type) {
226 DCHECK_NE(out_, nullptr);

Callers

nothing calls this directly

Calls 8

AddWithOverflowFunction · 0.85
IsMultipleOf8Function · 0.85
RequestRangeMethod · 0.80
OKFunction · 0.50
InvalidFunction · 0.50
ValueMethod · 0.45
ReadAtMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected