You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mapleFU (via GitHub)" <gi...@apache.org> on 2025/01/14 08:42:00 UTC
[PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
mapleFU opened a new pull request, #45252:
URL: https://github.com/apache/arrow/pull/45252
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
In DataPageV2, the levels and data will not be compressed together. So, we might get the "empty" data page buffer.
When meeting this, Snappy C++ will failed to decompress the `(input_len == 0, output_len == 0)` data.
### What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
Handling the case in `column_reader.cc`
### Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
* [ ] Will add
### Are there any user-facing changes?
Minor fix
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
-->
<!-- **This PR includes breaking changes to public APIs.** -->
<!--
Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
-->
<!-- **This PR contains a "Critical Fix".** -->
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914861178
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
> Ok, it's really a bug in parquet-java, because a 0-size buffer compressed to a 1-size buffer using Snappy.
I may not understand you correctly. The file with 0-sized snappy-compressed data is produced by parquet-mr: https://github.com/apache/arrow/issues/31992#issuecomment-2567972537
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2589325125
:warning: GitHub issue #31992 **has been automatically assigned in GitHub** to PR creator.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU merged PR #45252:
URL: https://github.com/apache/arrow/pull/45252
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1915040344
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Well, parquet-mr is parquet-java, right?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1916777813
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1774,5 +1774,35 @@ TEST_F(TestInt32Writer, WriteKeyValueMetadataEndToEnd) {
ASSERT_EQ("bar", value);
}
+TEST_F(TestValuesWriterInt32Type, AllNullsCompressionInPageV2) {
+ std::vector<Compression::type> compressions = {Compression::SNAPPY, Compression::GZIP,
Review Comment:
Can you add a comment referencing the GH issue number?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914774987
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Yes, which one do you prefer?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914776019
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
It will be useful to other callers if we fix this on the Snappy side.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914786014
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1774,5 +1774,29 @@ TEST_F(TestInt32Writer, WriteKeyValueMetadataEndToEnd) {
ASSERT_EQ("bar", value);
}
+TEST_F(TestValuesWriterInt32Type, AllNullsInPageV2) {
+#ifndef ARROW_WITH_SNAPPY
+ GTEST_SKIP() << "Test requires snappy compression";
+#endif
+ // Optional and non-repeated, with definition levels
+ // but no repetition levels
+ 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::SNAPPY);
Review Comment:
done
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914465079
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
+ // when all values are null. In this case, we can avoid decompressing
+ // the rest of the page.
+ int64_t decompressed_len = 0;
+ if (uncompressed_len - levels_byte_len != 0) {
Review Comment:
LGTM. Let's add a simple test to cover this.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1915140718
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Yes, I mean parquet-java is able to produce 0-sized compressed data as the example. How can I reproduce your case where 0 input is compressed to 1 byte?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1921953593
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
+ // when all values are null. In this case, we can avoid decompressing
+ // the rest of the page.
Review Comment:
```suggestion
// GH-31992: DataPageV2 may store only levels and no values when all
// values are null. In this case, Parquet java is known to produce a
// 0-len compressed area (which is invalid compressed input).
// See https://github.com/apache/parquet-java/issues/3122
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2602114257
Failed CI unrelated, merged
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1915040735
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
> So should I handle the `0,0` case in snappy 🤔?
No, sorry. We should work around it in Parquet.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2589718563
@pitrou @wgtmac
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914776019
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
It depends whether an empty buffer is a normal compression result or a shortcut taken by parquet-java. Let me see.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1915403932
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
It's not my case, it's just what Snappy produces when you ask it to compress 0 byte.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2593269087
Created: https://github.com/apache/parquet-java/issues/3122
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2603035300
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 9801801df3f75339f705264252c0eac189f5f2a3.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/35892110056) has more details. It also includes information about 13 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2592410810
@pitrou so what should I need to do to merge this? Should I check https://github.com/apache/arrow/pull/45252#discussion_r1916253275 in compression to check that "Compress" doesn't compress the zero-sized page? Or I should change other code?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2593050617
@mapleFU Can we open a bug for Parquet-java and reference it here?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1916253275
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Again, a 0-byte compressed data is invalid. It's probably a special case in the Parquet Java implementation.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914771344
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1774,5 +1774,29 @@ TEST_F(TestInt32Writer, WriteKeyValueMetadataEndToEnd) {
ASSERT_EQ("bar", value);
}
+TEST_F(TestValuesWriterInt32Type, AllNullsInPageV2) {
+#ifndef ARROW_WITH_SNAPPY
+ GTEST_SKIP() << "Test requires snappy compression";
+#endif
+ // Optional and non-repeated, with definition levels
+ // but no repetition levels
+ 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::SNAPPY);
Review Comment:
Why not test all compression algorithms?
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Can we fix this in the Snappy decompressor instead?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914780516
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
Ok, it's really a bug in parquet-java, because a 0-size buffer compressed to a 1-size buffer using Snappy.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "EnricoMi (via GitHub)" <gi...@apache.org>.
EnricoMi commented on PR #45252:
URL: https://github.com/apache/arrow/pull/45252#issuecomment-2782405895
Fixes #22459.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914816071
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
So should I handle the `0,0` case in snappy 🤔?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1914696573
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1774,5 +1774,29 @@ TEST_F(TestInt32Writer, WriteKeyValueMetadataEndToEnd) {
ASSERT_EQ("bar", value);
}
+TEST_F(TestValuesWriterInt32Type, AllNullsInPageV2) {
+#ifndef ARROW_WITH_SNAPPY
+ GTEST_SKIP() << "Test requires snappy compression";
+#endif
+ // Optional and non-repeated, with definition levels
+ // but no repetition levels
+ 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::SNAPPY);
+
+ auto writer =
+ this->BuildWriter(SMALL_SIZE, column_properties, ParquetVersion::PARQUET_2_LATEST,
+ ParquetDataPageVersion::V2);
+ writer->WriteBatch(this->values_.size(), this->def_levels_.data(), nullptr,
+ this->values_ptr_);
+ writer->Close();
+
+ ASSERT_EQ(100, this->metadata_num_values());
+ this->ReadColumn(Compression::SNAPPY);
+ ASSERT_EQ(0, this->values_read_);
Review Comment:
I've verified that the unittest test would test this 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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1916185673
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -580,13 +580,20 @@ std::shared_ptr<Buffer> SerializedPageReader::DecompressIfNeeded(
memcpy(decompressed, page_buffer->data(), levels_byte_len);
}
- // Decompress the values
- PARQUET_ASSIGN_OR_THROW(
- auto decompressed_len,
- decompressor_->Decompress(compressed_len - levels_byte_len,
- page_buffer->data() + levels_byte_len,
- uncompressed_len - levels_byte_len,
- decompression_buffer_->mutable_data() + levels_byte_len));
+ // GH-31992: DataPageV2 may store only levels and no values
Review Comment:
> it's just what Snappy produces when you ask it to compress 0 byte.
IMO that's:
1. "Compressed" Data is 0 byte
2. Actually, the levels holds k bytes ?
I don't know how parquet-java works, I tried parquet rust and it failed to read
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-31992: [C++][Parquet] Handling the special case when DataPageV2 values buffer is empty [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45252:
URL: https://github.com/apache/arrow/pull/45252#discussion_r1916775522
##########
cpp/src/parquet/column_writer_test.cc:
##########
@@ -1774,5 +1774,35 @@ TEST_F(TestInt32Writer, WriteKeyValueMetadataEndToEnd) {
ASSERT_EQ("bar", value);
}
+TEST_F(TestValuesWriterInt32Type, AllNullsCompressionInPageV2) {
+ std::vector<Compression::type> compressions = {Compression::SNAPPY, Compression::GZIP,
+ Compression::ZSTD, Compression::BROTLI,
+ Compression::LZ4};
+ for (auto compression : compressions) {
+ if (!Codec::IsAvailable(compression)) {
+ continue;
+ }
+ SCOPED_TRACE(compression);
Review Comment:
```suggestion
ARROW_SCOPED_TRACE("compression = ", Codec::GetCodecAsString(compression));
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org