jorisvandenbossche commented on a change in pull request #7233:
URL: https://github.com/apache/arrow/pull/7233#discussion_r427895147



##########
File path: cpp/src/arrow/ipc/reader.cc
##########
@@ -381,6 +381,42 @@ Status DecompressBuffers(Compression::type compression, 
const IpcReadOptions& op
       }
       arr->buffers[i] = std::move(uncompressed);
     }
+    for (size_t j = 0; j < arr->child_data.size(); ++j) {
+      for (size_t i = 0; i < arr->child_data[j]->buffers.size(); ++i) {
+        if (arr->child_data[j]->buffers[i] == nullptr) {
+          continue;
+        }
+        if (arr->child_data[j]->buffers[i]->size() == 0) {
+          continue;
+        }
+        if (arr->child_data[j]->buffers[i]->size() < 8) {
+          return Status::Invalid(
+              "Likely corrupted message, compressed buffers "
+              "are larger than 8 bytes by construction");
+        }
+        const uint8_t* data = arr->child_data[j]->buffers[i]->data();
+        int64_t compressed_size =
+            arr->child_data[j]->buffers[i]->size() - sizeof(int64_t);
+        int64_t uncompressed_size =
+            BitUtil::FromLittleEndian(util::SafeLoadAs<int64_t>(data));
+
+        ARROW_ASSIGN_OR_RAISE(auto uncompressed,
+                              AllocateBuffer(uncompressed_size, 
options.memory_pool));
+
+        int64_t actual_decompressed;
+        ARROW_ASSIGN_OR_RAISE(
+            actual_decompressed,
+            codec->Decompress(compressed_size, data + sizeof(int64_t), 
uncompressed_size,
+                              uncompressed->mutable_data()));
+        if (actual_decompressed != uncompressed_size) {
+          return Status::Invalid("Failed to fully decompress buffer, expected 
",
+                                 uncompressed_size, " bytes but decompressed ",
+                                 actual_decompressed);
+        }
+        arr->child_data[j]->buffers[i] = std::move(uncompressed);

Review comment:
       TODO: I need to rewrite this to factor out the common logic in a 
separate function (now this loop just duplicates the loop above to decompress 
`arr->buffers`)




----------------------------------------------------------------
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.

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


Reply via email to