This is an automated email from the ASF dual-hosted git repository.
cyb70289 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 740237e342c [C++] Remove capacity() check in
TDigest::TDigestImpl::Validate() (#52276)
740237e342c is described below
commit 740237e342c647967279abf6b36f2e2fafe46181
Author: Evan Brown <[email protected]>
AuthorDate: Thu Oct 15 23:05:56 2026 -0400
[C++] Remove capacity() check in TDigest::TDigestImpl::Validate() (#52276)
### Rationale for this change
`std::vector::reserve(delta_)` only guarantees `capacity() >= delta_`,
not `capacity() == delta_`. When the C++ standard library and allocator
use size-returning allocations (such as C++23 `allocate_at_least`),
`reserve(delta_)` can immediately set `capacity() > delta_`, causing
`TDigestImpl::Validate()` to fail with `"oversized tdigest buffer"` even
when the number of centroids is at most `delta_`.
Fixes issue #53777.
### What changes are included in this PR?
Remove the check of `capacity() > delta_` in
`TDigest::TDigestImpl::Validate()`.
### Are these changes tested?
Yes, covered by existing `TDigestTest` unit tests in
`cpp/src/arrow/util/tdigest_test.cc`.
### Are there any user-facing changes?
No.
### Was AI used for this PR?
**PR code and description written by:**
- [x] Human
- [x] AI
**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed
---
cpp/src/arrow/util/tdigest.cc | 4 ----
1 file changed, 4 deletions(-)
diff --git a/cpp/src/arrow/util/tdigest.cc b/cpp/src/arrow/util/tdigest.cc
index 36a83fb336d..7d9e316cd30 100644
--- a/cpp/src/arrow/util/tdigest.cc
+++ b/cpp/src/arrow/util/tdigest.cc
@@ -168,10 +168,6 @@ class TDigest::TDigestImpl {
if (total_weight != total_weight_) {
return Status::Invalid("tdigest total weight mismatch");
}
- // check if buffer expanded
- if (tdigests_[0].capacity() > delta_ || tdigests_[1].capacity() > delta_) {
- return Status::Invalid("oversized tdigest buffer");
- }
// check k-size
return merger_.Validate(tdigests_[current_], total_weight_);
}