MashrafeeAryan commented on code in PR #52580:
URL: https://github.com/apache/arrow/pull/52580#discussion_r4390284687


##########
cpp/src/parquet/column_writer.cc:
##########
@@ -1057,9 +1057,12 @@ void ColumnWriterImpl::BuildDataPageV2(int64_t 
definition_levels_rle_size,
   bool page_is_compressed = false;
   if (pager_->has_compressor() && values->size() > 0) {
     pager_->Compress(*values, compressor_temp_buffer_.get());
-    if (compressor_temp_buffer_->size() < values->size()) {
-      page_is_compressed = true;
-    }
+
+    const int64_t compressed = compressor_temp_buffer_->size();
+    const auto minimum = properties_->min_compression_savings();
+    page_is_compressed =
+        compressed < values->size() &&
+        1.0 - static_cast<double>(compressed) / values->size() >= minimum;

Review Comment:
   Hi @pitrou, thank you so much for the suggestion! I was thinking that since 
we set the default minimum at `0.0`, if the compressed size equals the original 
size, the savings would be `0.0`, so  the condition `0.0 >= 0.0` would pass.
   
   Would it make sense to keep `compressed < values->size()` so we avoid 
decompression with no space savings? Please let me know if I am overlooking 
something.



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