HuaHuaY commented on code in PR #48732:
URL: https://github.com/apache/arrow/pull/48732#discussion_r2674718029
##########
cpp/src/parquet/column_reader.cc:
##########
@@ -93,6 +93,27 @@ inline void CheckNumberDecoded(int64_t number_decoded,
int64_t expected) {
constexpr std::string_view kErrorRepDefLevelNotMatchesNumValues =
"Number of decoded rep / def levels do not match num_values in page
header";
+inline int64_t CountMaxDefLevels(const int16_t* levels, int64_t num_levels,
+ int16_t max_def_level) {
+ if (num_levels <= 0) {
+ return 0;
+ }
+ const int16_t rhs = static_cast<int16_t>(max_def_level - 1);
+ int64_t count = 0;
+ int64_t offset = 0;
+ for (; offset + 64 <= num_levels; offset += 64) {
+ const uint64_t bitmap =
+ internal::GreaterThanBitmap(levels + offset, 64, rhs);
+ count += static_cast<int64_t>(bit_util::PopCount(bitmap));
+ }
+ if (offset < num_levels) {
+ const uint64_t bitmap =
+ internal::GreaterThanBitmap(levels + offset, num_levels - offset, rhs);
+ count += static_cast<int64_t>(bit_util::PopCount(bitmap));
+ }
Review Comment:
```suggestion
for (int64_t offset = 0; offset < num_levels; offset += 64) {
const int64_t chunk_size = std::min<int64_t>(64, num_levels - offset);
const uint64_t bitmap =
internal::GreaterThanBitmap(levels + offset,
static_cast<int>(chunk_size), rhs);
count += static_cast<int64_t>(bit_util::PopCount(bitmap));
}
```
I suggest simplifying the for loop and if statement into one.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]