proost commented on code in PR #1198:
URL: https://github.com/apache/iceberg-cpp/pull/1198#discussion_r4768698293


##########
src/iceberg/puffin/puffin_format.cc:
##########
@@ -69,8 +89,32 @@ Result<std::vector<std::byte>> 
Decompress(PuffinCompressionCodec codec,
       return std::vector<std::byte>(input.begin(), input.end());
     case PuffinCompressionCodec::kLz4:
       return NotSupported("LZ4 decompression is not yet supported");
-    case PuffinCompressionCodec::kZstd:
-      return NotSupported("Zstd decompression is not yet supported");
+    case PuffinCompressionCodec::kZstd: {
+      const uint64_t frame_size = ZSTD_getFrameContentSize(input.data(), 
input.size());
+      if (frame_size == ZSTD_CONTENTSIZE_ERROR) {
+        return DecompressError("Content size of the compressed data is 
invalid");
+      }
+      if (frame_size == ZSTD_CONTENTSIZE_UNKNOWN) {
+        return DecompressError("Content size of the compressed data is 
unknown");
+      }
+      if (frame_size > std::numeric_limits<int32_t>::max()) {
+        // Matches Java, which rejects content sizes beyond the int range.
+        return DecompressError("Content size of the compressed data is too 
large");
+      }
+
+      std::vector<std::byte> output(frame_size);
+      const size_t decompressed_size =
+          ZSTD_decompress(output.data(), output.size(), input.data(), 
input.size());

Review Comment:
   Can you show me which case? Because i already have 
"frame_then_skippable_frame" and "frame_then_empty_frame" case.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to