pitrou commented on code in PR #45367:
URL: https://github.com/apache/arrow/pull/45367#discussion_r1980985198


##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1807,5 +1807,60 @@ TEST_F(TestValuesWriterInt32Type, 
AllNullsCompressionInPageV2) {
   }
 }
 
+#ifdef ARROW_WITH_ZSTD
+
+TEST_F(TestValuesWriterInt32Type, AvoidCompressedInDataPageV2) {
+  Compression::type compression = Compression::ZSTD;
+  auto verify_only_one_uncompress_page = [&](int total_num_values) {
+    ASSERT_OK_AND_ASSIGN(auto buffer, this->sink_->Finish());
+    auto source = std::make_shared<::arrow::io::BufferReader>(buffer);
+    ReaderProperties readerProperties;
+    std::unique_ptr<PageReader> page_reader = PageReader::Open(
+        std::move(source), total_num_values, compression, readerProperties);
+    auto data_page = 
std::static_pointer_cast<DataPageV2>(page_reader->NextPage());
+    ASSERT_TRUE(data_page != nullptr);
+    ASSERT_FALSE(data_page->is_compressed());
+    ASSERT_TRUE(page_reader->NextPage() == nullptr);
+  };
+  {
+    // zero-sized data buffer should be handled correctly.
+    this->SetUpSchema(Repetition::OPTIONAL);
+    this->GenerateData(SMALL_SIZE);
+    std::fill(this->def_levels_.begin(), this->def_levels_.end(), 0);
+    ColumnProperties column_properties;
+    column_properties.set_compression(compression);
+
+    auto writer =
+        this->BuildWriter(SMALL_SIZE, column_properties, 
ParquetVersion::PARQUET_2_LATEST,
+                          ParquetDataPageVersion::V2);
+    writer->WriteBatch(static_cast<int64_t>(values_.size()), 
this->def_levels_.data(),
+                       nullptr, this->values_ptr_);
+    writer->Close();

Review Comment:
   This can all be moved into `verify_only_one_uncompressed_page`, right?



##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1807,5 +1807,60 @@ TEST_F(TestValuesWriterInt32Type, 
AllNullsCompressionInPageV2) {
   }
 }
 
+#ifdef ARROW_WITH_ZSTD
+
+TEST_F(TestValuesWriterInt32Type, AvoidCompressedInDataPageV2) {
+  Compression::type compression = Compression::ZSTD;
+  auto verify_only_one_uncompress_page = [&](int total_num_values) {

Review Comment:
   Nit
   ```suggestion
     auto verify_only_one_uncompressed_page = [&](int total_num_values) {
   ```



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