Skip to content

Commit 5ea627b

Browse files
committed
A few more occurences of std::bit_width
1 parent 5b6a759 commit 5ea627b

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

cpp/src/arrow/util/rle_encoding_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,13 @@ TEST(BitRle, Random) {
916916
}
917917
parity = !parity;
918918
}
919+
// TODO: We can remove this condition once CRAN upgrades its macOS
920+
// SDK from 11.3.
921+
#if defined(__clang__) && !defined(__cpp_lib_bitops)
922+
if (!CheckRoundTrip(values, std::log2p1(values.size()))) {
923+
#else
919924
if (!CheckRoundTrip(values, std::bit_width(values.size()))) {
925+
#endif
920926
FAIL() << "failing seed: " << seed;
921927
}
922928
}

cpp/src/parquet/chunker_internal.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ uint64_t CalculateMask(int64_t min_chunk_size, int64_t max_chunk_size, int norm_
8686

8787
// assuming that the gear hash has a uniform distribution, we can calculate the mask
8888
// by taking the floor(log2(target_size))
89+
// TODO: We can remove this condition once CRAN upgrades its macOS
90+
// SDK from 11.3.
91+
#if defined(__clang__) && !defined(__cpp_lib_bitops)
92+
auto target_bits = std::log2p1(static_cast<uint64_t>(target_size));
93+
#else
8994
auto target_bits = std::bit_width(static_cast<uint64_t>(target_size));
95+
#endif
9096
int mask_bits = target_bits == 0 ? 0 : static_cast<int>(target_bits - 1);
9197

9298
// a user defined `norm_level` can be used to adjust the mask size, hence the matching

cpp/src/parquet/encoder.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,15 @@ void DeltaBitPackEncoder<DType>::FlushBlock() {
11671167

11681168
// The minimum number of bits required to write any of values in deltas_ vector.
11691169
// See overflow comment above.
1170+
// TODO: We can remove this condition once CRAN upgrades its macOS
1171+
// SDK from 11.3.
1172+
#if defined(__clang__) && !defined(__cpp_lib_bitops)
1173+
const auto bit_width = bit_width_data[i] =
1174+
std::log2p1(static_cast<UT>(max_delta) - static_cast<UT>(min_delta));
1175+
#else
11701176
const auto bit_width = bit_width_data[i] =
11711177
std::bit_width(static_cast<UT>(max_delta) - static_cast<UT>(min_delta));
1178+
#endif
11721179

11731180
for (uint32_t j = start; j < start + values_current_mini_block; j++) {
11741181
// Convert delta to frame of reference. See overflow comment above.

0 commit comments

Comments
 (0)