This is an automated email from the ASF dual-hosted git repository.
wgtmac 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 fae42627f89 MINOR: [C++][Parquet] Clean up chunker test assertions
(#55637)
fae42627f89 is described below
commit fae42627f892c96cf5483ca8594c17318fb171e5
Author: Sumedh Pimplikar <[email protected]>
AuthorDate: Tue Nov 17 09:13:33 2026 +0530
MINOR: [C++][Parquet] Clean up chunker test assertions (#55637)
### Rationale for this change
I have been studying the Apache Arrow codebase for the past couple of weeks
and am still relatively new to open source. I had my first documentation fix
merged a couple of days ago, and while continuing to read through the C++ and
Parquet code, I noticed a few small cleanup opportunities in the
content-defined chunking tests and related documentation comments.
These changes are intentionally small and do not alter production behavior.
They improve readability, remove an unnecessary copy, and clean up an
accidental duplicate assertion.
### What changes are included in this PR?
- Fix four spelling errors in C++ comments:
- `preceeding` to `preceding`
- `specifed` to `specified`
- `determinisic` to `deterministic`
- `lenght` to `length`
- Replace `diffs.size() == 0` with `diffs.empty()` in the page-length
assertion helpers. This expresses the intent more directly and is the idiomatic
way to check whether a container has no elements.
- Remove a duplicated dictionary-page assertion in
`AssertContentDefinedChunkSizes`.
The duplicate initially caught my attention because I was unsure whether
the two identical assertions were intended as some kind of additional failure
protection. After looking into the helper's callers, the original commit, and
GoogleTest's assertion behavior, I found that both assertions checked exactly
the same condition. Since `ASSERT_EQ` is fatal and returns from the helper when
it fails, the second assertion would never run after a failure in the first
one. When the first asse [...]
- Change the local `page_lengths` variable to a `const` reference to avoid
copying the page-length vector unnecessarily.
### Are these changes tested?
No runtime tests were run. The changes are limited to comments and small
test-code cleanups, with no production behavior or public API changes.
`git diff --check` was run successfully though. A focused C++ test build
was not available in the checkout, so the Parquet test suite was not run
locally.
### Are there any user-facing changes?
No. These are test and comment cleanups only.
### Was AI used for this PR?
AI was used to help search through the codebase, investigate the history
and behavior of the duplicated assertion, and review the proposed small cleanup
changes. The changes and reasoning were all reviewed before submission.
**PR code and description written by:**
- [x] Human
- [x] AI
**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed
Note - The duplicated assertion seemed redundant based on the current
helper behavior and GoogleTest's fatal assertion semantics. If it was
originally intended to serve a purpose that I have overlooked, please let me
know and I would be happy to revise my change.
Lead-authored-by: Sumedh Pimplikar <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Gang Wu <[email protected]>
---
cpp/src/arrow/compute/row/grouper.h | 4 ++--
cpp/src/parquet/chunker_internal_test.cc | 11 +++++------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/cpp/src/arrow/compute/row/grouper.h
b/cpp/src/arrow/compute/row/grouper.h
index 9424559385b..5922a376c14 100644
--- a/cpp/src/arrow/compute/row/grouper.h
+++ b/cpp/src/arrow/compute/row/grouper.h
@@ -44,7 +44,7 @@ struct ARROW_COMPUTE_EXPORT Segment {
int64_t length;
/// \brief whether the segment may be extended by a next one
bool is_open;
- /// \brief whether the segment extends a preceeding one
+ /// \brief whether the segment extends a preceding one
bool extends;
};
@@ -58,7 +58,7 @@ inline bool operator!=(const Segment& segment1, const
Segment& segment2) {
/// \brief a helper class to divide a batch into segments of equal values
///
-/// For example, given a batch with two columns specifed as segment keys:
+/// For example, given a batch with two columns specified as segment keys:
///
/// A A [other columns]...
/// A A ...
diff --git a/cpp/src/parquet/chunker_internal_test.cc
b/cpp/src/parquet/chunker_internal_test.cc
index 7b4c9bb7cce..30e930326b9 100644
--- a/cpp/src/parquet/chunker_internal_test.cc
+++ b/cpp/src/parquet/chunker_internal_test.cc
@@ -62,7 +62,7 @@ using ::testing::Bool;
using ::testing::Combine;
using ::testing::Values;
-// generate determinisic and platform-independent data
+// generate deterministic and platform-independent data
inline uint64_t hash(uint64_t seed, uint64_t index) {
uint64_t h = (index + seed) * 0xc4ceb9fe1a85ec53ull;
h ^= h >> 33;
@@ -658,7 +658,7 @@ void AssertPageLengthDifferences(const ColumnInfo&
original, const ColumnInfo& m
// exact_number_of_larger_diffs, and exact_number_of_smaller_diffs
parameters specify
// the expected number of differences with equal, larger, and smaller sums
of the page
// lengths respectively. The edit_length parameter is used to verify that
the page
- // lenght differences are exactly equal to the edit_length.
+ // length differences are exactly equal to the edit_length.
auto diffs = FindDifferences(original.page_lengths, modified.page_lengths);
// Note, the assertion function assumes that all edits are made using the
same edit
@@ -684,7 +684,7 @@ void AssertPageLengthDifferences(const ColumnInfo&
original, const ColumnInfo& m
if (diffs.size() != expected_number_of_diffs) {
PrintDifferences(original.page_lengths, modified.page_lengths, diffs);
}
- if (diffs.size() == 0) {
+ if (diffs.empty()) {
// no differences found, the arrays are equal
ASSERT_TRUE(original.page_lengths == modified.page_lengths);
}
@@ -734,7 +734,7 @@ void AssertPageLengthDifferences(const ColumnInfo&
original, const ColumnInfo& m
ASSERT_EQ(left_sum, right_sum);
}
- if (diffs.size() == 0) {
+ if (diffs.empty()) {
// no differences found, the arrays are equal
ASSERT_TRUE(original.page_lengths == modified.page_lengths);
}
@@ -804,14 +804,13 @@ void AssertContentDefinedChunkSizes(const
std::shared_ptr<::arrow::ChunkedArray>
ASSERT_FALSE(column_info.has_dictionary_page);
} else {
ASSERT_EQ(column_info.has_dictionary_page, expect_dictionary_page);
- ASSERT_EQ(column_info.has_dictionary_page, expect_dictionary_page);
}
if (::arrow::is_fixed_width(type_id) ||
::arrow::is_base_binary_like(type_id) ||
::arrow::is_binary_view_like(type_id)) {
int64_t offset = 0;
- auto page_lengths = column_info.page_lengths;
+ const auto& page_lengths = column_info.page_lengths;
for (size_t i = 0; i < page_lengths.size() - 1; i++) {
// since CDC chunking is applied on the logical values before any
parquet encoding
// we first slice the array to get the logical array and then calculate
the CDC