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

Method ReadBuffer

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

Source from the content-addressed store, hash-verified

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