Skip to content

Commit 53453c8

Browse files
committed
Address reviewer comments
1 parent 9ace2e6 commit 53453c8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cpp/src/arrow/util/bpacking_test.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ std::vector<Uint> GenerateRandomValuesForPacking(int num_values, int bit_width)
5656
if constexpr (std::is_same_v<Uint, bool>) {
5757
random_is_valid(num_values, 0.5, &out, kSeed);
5858
} else {
59-
const uint64_t max = (uint64_t{1} << (static_cast<uint64_t>(bit_width) - 1)) - 1;
59+
const uint64_t max = bit_util::LeastSignificantBitMask<uint64_t, true>(bit_width);
6060
rand_uniform_int(out.size(), kSeed, /* min= */ decltype(max){0}, max, out.data());
6161
}
6262
return out;
@@ -93,14 +93,13 @@ std::vector<uint8_t> PackValues(const std::vector<Int>& values, int num_values,
9393
bit_util::BitWriter writer(out.data(), num_bytes);
9494

9595
// Write a first 0 value to make an offset
96-
bool written = writer.PutValue(0, bit_offset);
96+
const bool written = writer.PutValue(0, bit_offset);
97+
ARROW_DCHECK(written);
9798
for (const auto& v : values) {
98-
written &= writer.PutValue(v, bit_width);
99+
const bool written = writer.PutValue(v, bit_width);
100+
ARROW_DCHECK(written);
99101
}
100102

101-
if (!written) {
102-
throw std::runtime_error("Cannot write move values");
103-
}
104103
writer.Flush();
105104

106105
return out;

0 commit comments

Comments
 (0)