HuaHuaY commented on code in PR #55856:
URL: https://github.com/apache/arrow/pull/55856#discussion_r4738546837


##########
cpp/src/parquet/column_writer.cc:
##########
@@ -1066,16 +1066,17 @@ void ColumnWriterImpl::BuildDataPageV2(int64_t 
definition_levels_rle_size,
     page_is_compressed =
         (1.0 - static_cast<double>(compressed) / values->size()) >= minimum;
   }
-  std::shared_ptr<Buffer> compressed_values =
-      (page_is_compressed ? compressor_temp_buffer_ : values);
-
-  // Concatenate uncompressed levels and the possibly compressed values
-  int64_t combined_size =
-      definition_levels_rle_size + repetition_levels_rle_size + 
compressed_values->size();
-  std::shared_ptr<ResizableBuffer> combined = AllocateBuffer(allocator_, 
combined_size);
-
-  ConcatenateBuffers(definition_levels_rle_size, repetition_levels_rle_size,
-                     compressed_values, combined->mutable_data());
+  std::shared_ptr<Buffer> page_buffer =
+      page_is_compressed ? compressor_temp_buffer_ : values;

Review Comment:
   There is an issue here, though I am not sure if it should block this PR.
   
   `PageWriter` is a pure virtual class with the method signature `virtual 
int64_t WriteDataPage(const DataPage& page) = 0`. If a custom class inherits 
from `PageWriter` and invokes `std::shared_ptr<Buffer> Page::buffer() const { 
return buffer_; }`, it can retrieve a `shared_ptr` from the `const DataPage& 
page` argument.
   
   However, with this change, `compressor_temp_buffer_` is written out 
directly; consequently, downstream components can no longer rely on this 
`shared_ptr` remaining valid during the next call to `BuildDataPageV2`. That 
said, the fact that `const DataPage& page` is passed as an argument arguably 
carries the implicit semantic that the `page` object might become invalid after 
the call returns.



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