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

Function ReadMessageInternal

cpp/src/arrow/ipc/message.cc:455–472  ·  view source on GitHub ↗

Common helper for the two ReadMessage overloads that take a file + offset. When body_length is provided, metadata and body are read in a single IO. When body_length is absent, metadata is read first, then the body is read separately.

Source from the content-addressed store, hash-verified

453// When body_length is absent, metadata is read first, then the body is read
454// separately.
455static Result<std::unique_ptr<Message>> ReadMessageInternal(
456 int64_t offset, int32_t metadata_length, std::optional<int64_t> body_length,
457 io::RandomAccessFile* file, const FieldsLoaderFunction& fields_loader) {
458 ReadMessageState state;
459
460 if (metadata_length < state.decoder->next_required_size()) {
461 return Status::Invalid("metadata_length should be at least ",
462 state.decoder->next_required_size());
463 }
464 // When body_length is known, read metadata + body in one IO call.
465 // Otherwise, read only metadata first.
466 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Buffer> metadata,
467 file->ReadAt(offset, metadata_length + body_length.value_or(0),
468 /*allow_short_read=*/false));
469
470 return ReadMessageContinued(offset, metadata_length, body_length, metadata, file,
471 fields_loader, &state);
472}
473
474Result<std::unique_ptr<Message>> ReadMessage(int64_t offset, int32_t metadata_length,
475 io::RandomAccessFile* file,

Callers 1

ReadMessageFunction · 0.85

Calls 5

ReadMessageContinuedFunction · 0.85
ARROW_ASSIGN_OR_RAISEFunction · 0.70
InvalidFunction · 0.50
next_required_sizeMethod · 0.45
ReadAtMethod · 0.45

Tested by

no test coverage detected