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/06 08:05:26 UTC
[PR] GH-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
mapleFU opened a new pull request, #41546:
URL: https://github.com/apache/arrow/pull/41546
<!--
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.
-->
See https://github.com/apache/arrow/issues/41545
### 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.
-->
Remove `encoded_size_` and uses `sink_.length()` as `encoded_size_`.
### 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)?
-->
No
### Are there any user-facing changes?
No
<!--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590752598
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2768,6 +2767,10 @@ class DeltaLengthByteArrayEncoder : public EncoderImpl,
return Status::Invalid(
"Parquet cannot store strings with size 2GB or more, got: ", view.size());
}
+ if (ARROW_PREDICT_FALSE(view.size() + sink_.length() >
+ std::numeric_limits<int32_t>::max())) {
Review Comment:
CI is throwing:
```bash
comparison of integer expressions of different signedness: 'long unsigned int' and 'int'
```
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2095676239
The Appveyor issue appears on master as well.
--
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-41545: [C++][Parquet] Fix DeltaLengthByteArrayEncoder::EstimatedDataEncodedSize [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2099476294
After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 51689a040cbe3dee8702cd899a33fa62e0616bf1.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/24705978447) has more details. It also includes information about 3 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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590776471
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2740,13 +2740,12 @@ class DeltaLengthByteArrayEncoder : public EncoderImpl,
: EncoderImpl(descr, Encoding::DELTA_LENGTH_BYTE_ARRAY,
pool = ::arrow::default_memory_pool()),
sink_(pool),
- length_encoder_(nullptr, pool),
- encoded_size_{0} {}
+ length_encoder_(nullptr, pool) {}
std::shared_ptr<Buffer> FlushValues() override;
int64_t EstimatedDataEncodedSize() override {
- return encoded_size_ + length_encoder_.EstimatedDataEncodedSize();
+ return sink_.length() + length_encoder_.EstimatedDataEncodedSize();
Review Comment:
Ah sorry in this case they wouldn't be different as we call `sink_.Reserve` (and not `sink_.Resize` as I assumed).
--
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-41545: [C++][Parquet] Fix DeltaLengthByteArrayEncoder::EstimatedDataEncodedSize [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2098340275
@mapleFU Can you rebase?
--
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-41545: [C++][Parquet] Fix DeltaLengthByteArrayEncoder::EstimatedDataEncodedSize [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2098829047
Yes, this is an external issue and should be solved once the rebuilt setuptools-scm packages propagate after https://github.com/conda-forge/setuptools_scm-feedstock/pull/74
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2096069246
Sure, I can add it for this case(DeltaLengthByteArrayEncoder statistics) . However these value is "estimated", we use this during set a page-size-limit and check if limit exceeds. How could I elaborate the number since it could be larger or smaller than the values? ( it's smaller than exact values for dict + byte-array, and this doesn't affect the `ColumnStats` 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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1592051310
##########
cpp/src/parquet/encoding_test.cc:
##########
@@ -2160,6 +2165,20 @@ TEST(DeltaLengthByteArrayEncodingAdHoc, ArrowBinaryDirectPut) {
auto CheckSeed = [&](std::shared_ptr<::arrow::Array> values) {
ASSERT_NO_THROW(encoder->Put(*values));
+ int64_t expected_array_size = 0;
+ if (auto* string_array = dynamic_cast<const ::arrow::StringArray*>(values.get());
Review Comment:
`StringArray` inherits from `BinaryArray`, so this is not necessary.
##########
cpp/src/parquet/encoding_test.cc:
##########
@@ -2160,6 +2165,20 @@ TEST(DeltaLengthByteArrayEncodingAdHoc, ArrowBinaryDirectPut) {
auto CheckSeed = [&](std::shared_ptr<::arrow::Array> values) {
ASSERT_NO_THROW(encoder->Put(*values));
+ int64_t expected_array_size = 0;
+ if (auto* string_array = dynamic_cast<const ::arrow::StringArray*>(values.get());
Review Comment:
In other words, you can just use a single `checked_cast`.
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590767517
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2803,15 +2806,15 @@ void DeltaLengthByteArrayEncoder<DType>::Put(const T* src, int num_values) {
const int batch_size = std::min(kBatchSize, num_values - idx);
for (int j = 0; j < batch_size; ++j) {
const int32_t len = src[idx + j].len;
- if (AddWithOverflow(total_increment_size, len, &total_increment_size)) {
+ if (ARROW_PREDICT_FALSE(
+ AddWithOverflow(total_increment_size, len, &total_increment_size))) {
throw ParquetException("excess expansion in DELTA_LENGTH_BYTE_ARRAY");
}
lengths[j] = len;
}
length_encoder_.Put(lengths.data(), batch_size);
}
-
- if (AddWithOverflow(encoded_size_, total_increment_size, &encoded_size_)) {
+ if (sink_.length() + total_increment_size > std::numeric_limits<int32_t>::max()) {
Review Comment:
It doesn't matter since it's not in loop?
--
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-41545: [C++][Parquet] Fix DeltaLengthByteArrayEncoder::EstimatedDataEncodedSize [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #41546:
URL: https://github.com/apache/arrow/pull/41546
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "rok (via GitHub)" <gi...@apache.org>.
rok commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590748410
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2740,13 +2740,12 @@ class DeltaLengthByteArrayEncoder : public EncoderImpl,
: EncoderImpl(descr, Encoding::DELTA_LENGTH_BYTE_ARRAY,
pool = ::arrow::default_memory_pool()),
sink_(pool),
- length_encoder_(nullptr, pool),
- encoded_size_{0} {}
+ length_encoder_(nullptr, pool) {}
std::shared_ptr<Buffer> FlushValues() override;
int64_t EstimatedDataEncodedSize() override {
- return encoded_size_ + length_encoder_.EstimatedDataEncodedSize();
+ return sink_.length() + length_encoder_.EstimatedDataEncodedSize();
Review Comment:
This will probably be slightly less precise (because `sink_.resize ` will resize to multiple of 64 bytes), but that's inline with expectations. I wonder if this would reduce number of allocations and improve performance?
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590752421
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2740,13 +2740,12 @@ class DeltaLengthByteArrayEncoder : public EncoderImpl,
: EncoderImpl(descr, Encoding::DELTA_LENGTH_BYTE_ARRAY,
pool = ::arrow::default_memory_pool()),
sink_(pool),
- length_encoder_(nullptr, pool),
- encoded_size_{0} {}
+ length_encoder_(nullptr, pool) {}
std::shared_ptr<Buffer> FlushValues() override;
int64_t EstimatedDataEncodedSize() override {
- return encoded_size_ + length_encoder_.EstimatedDataEncodedSize();
+ return sink_.length() + length_encoder_.EstimatedDataEncodedSize();
Review Comment:
Would `length` and `capacity` be different, since "length" is only the logical size in `sink_`?
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2096441928
@pitrou I add test just in the "TEST({DeltaLengthByte|Plain}ArrayEncodingAdHoc, ArrowBinaryDirectPut)" 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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2096072831
Hmm... what is estimated exactly? Are we talking about the statistics written to the Parquet file, or about something else?
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2096073066
I can add test for ByteArray + Non-Dict encoding as a first 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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1590766609
##########
cpp/src/parquet/encoding.cc:
##########
@@ -2803,15 +2806,15 @@ void DeltaLengthByteArrayEncoder<DType>::Put(const T* src, int num_values) {
const int batch_size = std::min(kBatchSize, num_values - idx);
for (int j = 0; j < batch_size; ++j) {
const int32_t len = src[idx + j].len;
- if (AddWithOverflow(total_increment_size, len, &total_increment_size)) {
+ if (ARROW_PREDICT_FALSE(
+ AddWithOverflow(total_increment_size, len, &total_increment_size))) {
throw ParquetException("excess expansion in DELTA_LENGTH_BYTE_ARRAY");
}
lengths[j] = len;
}
length_encoder_.Put(lengths.data(), batch_size);
}
-
- if (AddWithOverflow(encoded_size_, total_increment_size, &encoded_size_)) {
+ if (sink_.length() + total_increment_size > std::numeric_limits<int32_t>::max()) {
Review Comment:
ARROW_PREDICT_FALSE ?
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #41546:
URL: https://github.com/apache/arrow/pull/41546#discussion_r1592074718
##########
cpp/src/parquet/encoding_test.cc:
##########
@@ -2160,6 +2165,20 @@ TEST(DeltaLengthByteArrayEncodingAdHoc, ArrowBinaryDirectPut) {
auto CheckSeed = [&](std::shared_ptr<::arrow::Array> values) {
ASSERT_NO_THROW(encoder->Put(*values));
+ int64_t expected_array_size = 0;
+ if (auto* string_array = dynamic_cast<const ::arrow::StringArray*>(values.get());
Review Comment:
Updated, thanks!
--
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-41545: [C++][Parquet] Fix DeltaLengthByteArrayEncoder::EstimatedDataEncodedSize [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2098825940
@pitrou rebased but ci still failed, seems it doesn't help :-(
--
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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2095410053
:warning: GitHub issue #41545 **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-41545: [C++][Parquet] DeltaLengthByteArrayEncoder add estimated size when Put(Array) [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #41546:
URL: https://github.com/apache/arrow/pull/41546#issuecomment-2096082903
> Hmm... what is estimated exactly?
Currently encoder estimated "the values size after encoding but not compressed". When using DeltaLengthByteArray, we use a smaller `data_pagesize()`, however, when `Put(Array)` called, the page haven't reached the size limit and never being flushed. It causing the page size exceeds `INT32_MAX`
https://github.com/apache/arrow/blob/d10ebf055a393c94a693097db1dca08ff86745bd/cpp/src/parquet/column_writer.cc#L1561-L1563
This is an "Estimated" size, so I'm not sure how I test it generally. I can testing it for each encoding
--
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