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 2024/05/07 08:26:59 UTC
[PR] GH-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
mapleFU opened a new pull request, #41565:
URL: https://github.com/apache/arrow/pull/41565
<!--
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}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${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.
-->
This problem is raised from https://github.com/apache/arrow/pull/40094 . Original bug fixed here: https://github.com/apache/arrow/pull/34140 , but this is corrupt in https://github.com/apache/arrow/pull/40094 .
### 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.
-->
Refine checking
### 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?
Bugfix
<!--
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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41565:
URL: https://github.com/apache/arrow/pull/41565#issuecomment-2097737061
:warning: GitHub issue #41562 **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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #41565:
URL: https://github.com/apache/arrow/pull/41565#issuecomment-2099297054
After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 9cf0ee722ba048f3f305b38e536fa726eff9c813.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/24701430572) has more details. It also includes information about 8 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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #41565:
URL: https://github.com/apache/arrow/pull/41565#discussion_r1592591698
##########
cpp/src/parquet/encoding_test.cc:
##########
@@ -1383,7 +1383,7 @@ class TestByteStreamSplitEncoding : public TestEncodingBase<Type> {
encoder->PutSpaced(draws_, num_values_, valid_bits, valid_bits_offset);
encode_buffer_ = encoder->FlushValues();
ASSERT_EQ(encode_buffer_->size(), physical_byte_width() * (num_values_ - null_count));
- decoder->SetData(num_values_ - null_count, encode_buffer_->data(),
+ decoder->SetData(num_values_, encode_buffer_->data(),
Review Comment:
Ouch. Can we also improve the docstring for `Decoder::SetData`, to make it clear that the `num_values` parameter also includes null 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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #41565:
URL: https://github.com/apache/arrow/pull/41565#issuecomment-2098677999
@github-actions crossbow submit -g cpp
--
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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41565:
URL: https://github.com/apache/arrow/pull/41565#issuecomment-2098686834
Revision: 7daee1c89df8b7108fc8a8e48f82f33c0b00f8c8
Submitted crossbow builds: [ursacomputing/crossbow @ actions-655ed96d55](https://github.com/ursacomputing/crossbow/branches/all?query=actions-655ed96d55)
|Task|Status|
|----|------|
|test-alpine-linux-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946141/job/24687643541)|
|test-build-cpp-fuzz|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945714/job/24687642385)|
|test-conda-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946695/job/24687644988)|
|test-conda-cpp-valgrind|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946156/job/24687644353)|
|test-cuda-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946144/job/24687643464)|
|test-debian-12-cpp-amd64|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945910/job/24687643376)|
|test-debian-12-cpp-i386|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946930/job/24687646028)|
|test-fedora-39-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945727/job/24687642426)|
|test-ubuntu-20.04-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945838/job/24687643078)|
|test-ubuntu-20.04-cpp-bundled|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946513/job/24687644822)|
|test-ubuntu-20.04-cpp-minimal-with-formats|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945954/job/24687643909)|
|test-ubuntu-20.04-cpp-thread-sanitizer|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945736/job/24687642381)|
|test-ubuntu-22.04-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946710/job/24687645557)|
|test-ubuntu-22.04-cpp-20|[](https://github.com/ursacomputing/crossbow/actions/runs/8987945717/job/24687642442)|
|test-ubuntu-22.04-cpp-emscripten|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946009/job/24687643753)|
|test-ubuntu-22.04-cpp-no-threading|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946142/job/24687643738)|
|test-ubuntu-24.04-cpp|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946346/job/24687644839)|
|test-ubuntu-24.04-cpp-gcc-14|[](https://github.com/ursacomputing/crossbow/actions/runs/8987946201/job/24687644500)|
--
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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #41565:
URL: https://github.com/apache/arrow/pull/41565#discussion_r1592614269
##########
cpp/src/parquet/encoding_test.cc:
##########
@@ -1383,7 +1383,7 @@ class TestByteStreamSplitEncoding : public TestEncodingBase<Type> {
encoder->PutSpaced(draws_, num_values_, valid_bits, valid_bits_offset);
encode_buffer_ = encoder->FlushValues();
ASSERT_EQ(encode_buffer_->size(), physical_byte_width() * (num_values_ - null_count));
- decoder->SetData(num_values_ - null_count, encode_buffer_->data(),
+ decoder->SetData(num_values_, encode_buffer_->data(),
Review Comment:
done. This part is so tricky, I may revisit it later
--
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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #41565:
URL: https://github.com/apache/arrow/pull/41565#discussion_r1592639889
##########
cpp/src/parquet/encoding.h:
##########
@@ -255,6 +255,10 @@ class Decoder {
// Sets the data for a new page. This will be called multiple times on the same
// decoder and should reset all internal state.
+ //
+ // In current implementations, `num_values` is the `num_values` field in the
+ // data page header, which may greater than the number of values in the data
+ // buffer.
Review Comment:
```suggestion
// `num_values` comes from the data page header, and may be greater than the number of
// physical values in the data buffer if there are some omitted (null) values.
// `len`, on the other hand, is the size in bytes of the data buffer and
// directly relates to the number of physical 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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #41565:
URL: https://github.com/apache/arrow/pull/41565
--
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-41562: [C++][Parquet] Decoding: Fix num_value handling in ByteStreamSplitDecoder [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #41565:
URL: https://github.com/apache/arrow/pull/41565#discussion_r1592585953
##########
cpp/src/parquet/encoding.cc:
##########
@@ -3694,12 +3694,23 @@ class ByteStreamSplitDecoderBase : public DecoderImpl,
ByteStreamSplitDecoderBase(const ColumnDescriptor* descr, int byte_width)
: DecoderImpl(descr, Encoding::BYTE_STREAM_SPLIT), byte_width_(byte_width) {}
- void SetData(int num_values, const uint8_t* data, int len) override {
- if (static_cast<int64_t>(num_values) * byte_width_ != len) {
+ void SetData(int num_values, const uint8_t* data, int len) final {
+ // Check that the data size is consistent with the number of values
+ // The spec requires that the data size is a multiple of the number of values,
+ // see: https://github.com/apache/parquet-format/pull/192 .
+ // GH-41562: passed in `num_values` may include nulls, so we need to check and
+ // adjust the number of values.
+ if (static_cast<int64_t>(num_values) * byte_width_ < len) {
throw ParquetException("Data size (" + std::to_string(len) +
") does not match number of values in BYTE_STREAM_SPLIT (" +
Review Comment:
```suggestion
") is too small for the number of values in BYTE_STREAM_SPLIT (" +
```
--
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