niyue commented on a change in pull request #11486:
URL: https://github.com/apache/arrow/pull/11486#discussion_r732839467



##########
File path: cpp/src/arrow/ipc/message.cc
##########
@@ -279,8 +279,37 @@ std::string FormatMessageType(MessageType type) {
   return "unknown";
 }
 
+Status ReadFieldsSubset(int64_t offset, int32_t metadata_length,
+                        io::RandomAccessFile* file,
+                        const FieldsLoaderFunction& fields_loader,
+                        const std::shared_ptr<Buffer>& metadata, int64_t 
required_size,
+                        std::shared_ptr<Buffer>& body) {
+  const flatbuf::Message* message = nullptr;
+  uint8_t continuation_metadata_size = sizeof(int32_t) + sizeof(int32_t);
+  // skip 8 bytes (32-bit continuation indicator + 32-bit little-endian length 
prefix)
+  RETURN_NOT_OK(internal::VerifyMessage(metadata->data() + 
continuation_metadata_size,
+                                        metadata->size() - 
continuation_metadata_size,
+                                        &message));
+
+  auto batch = message->header_as_RecordBatch();
+  auto io_recorded_random_access_file = 
std::unique_ptr<IoRecordedRandomAccessFile>(
+      new IoRecordedRandomAccessFile(required_size));
+  RETURN_NOT_OK(fields_loader(batch, io_recorded_random_access_file.get()));
+  auto io_ops = io_recorded_random_access_file->GetRecordedIoOps();
+  for (auto const& io_op : io_ops) {
+    auto read_result = file->ReadAt(offset + metadata_length + io_op.first, 
io_op.second,
+                                    body->mutable_data() + io_op.first);

Review comment:
       The recorded read IO operations are replayed here to really reading data 
from the file into `body`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to