Skip to content

Commit 6fc9785

Browse files
committed
Adjust for review
1 parent 41fc6c7 commit 6fc9785

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

cpp/src/arrow/util/bit_util.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ template <typename Uint>
183183
struct CopyBitsParams {
184184
Uint src = {};
185185
Uint dst = {};
186-
Uint start = {};
187-
Uint end = {};
186+
int start = {};
187+
int end = {};
188188
};
189189

190190
/// Copy a contiguous span of bits from src into dst.
@@ -195,19 +195,20 @@ struct CopyBitsParams {
195195
/// guarantee that the range of bits to copy does not cover the whole range.
196196
template <typename Uint, bool kAllowFullCopy = true>
197197
[[nodiscard]] constexpr Uint CopyBitsInInteger(const CopyBitsParams<Uint>& params) {
198-
constexpr auto kUintSizeBits = static_cast<Uint>(sizeof(Uint) * 8);
198+
constexpr auto kUintSizeBits = static_cast<int>(sizeof(Uint) * 8);
199199
assert(params.start <= params.end);
200200
assert(params.start < kUintSizeBits);
201201
assert(params.end <= kUintSizeBits);
202202

203-
const auto length = static_cast<Uint>(params.end - params.start);
203+
const int length = params.end - params.start;
204204
if constexpr (kAllowFullCopy) {
205205
if (length == kUintSizeBits) {
206206
return params.src;
207207
}
208208
}
209209
assert(length < kUintSizeBits);
210-
const Uint mask = LeastSignificantBitMask<Uint, false>(length) << params.start;
210+
const Uint mask =
211+
static_cast<Uint>(LeastSignificantBitMask<Uint, false>(length) << params.start);
211212
return (~mask & params.dst) | (mask & params.src);
212213
}
213214

cpp/src/arrow/util/rle_bitmap_internal.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,24 @@ class RleRunToBitmapDecoder {
9898
/// Return how much the decoder would advance if asked to.
9999
///
100100
/// Does not modify input.
101-
rle_size_t AdvanceCapacity(rle_size_t batch_size) const noexcept {
101+
rle_size_t GetAdvanceCapacity(rle_size_t batch_size) const noexcept {
102102
const auto n_vals = std::min(batch_size, remaining());
103103
return n_vals;
104104
}
105105

106106
/// Advance by as many values as provided or until exhaustion of the decoder.
107107
/// Return the number of values skipped.
108108
[[nodiscard]] rle_size_t Advance(rle_size_t batch_size) {
109-
const auto n_vals = AdvanceCapacity(batch_size);
109+
const auto n_vals = GetAdvanceCapacity(batch_size);
110110
values_left_ -= n_vals;
111111
ARROW_DCHECK_GE(remaining(), 0);
112112
return n_vals;
113113
}
114114

115-
/// Get the next value and return false if there are no more.
115+
/// Read the next value into `out` and return false if there are no more.
116116
[[nodiscard]] bool Get(BitmapSpanMut out) { return GetBatch(out, 1) == 1; }
117117

118-
/// Get a batch of values return the number of decoded elements.
118+
/// Get a batch of values into `out` and return the number of decoded elements.
119119
///
120120
/// May write fewer elements to the output than requested if there are not
121121
/// enough values left.
@@ -140,7 +140,7 @@ class RleRunToBitmapDecoder {
140140

141141
// TRAILER: Writing inside the last byte if caller asked for non multiple of 8 values
142142
const auto n_last_vals = std::min(batch_size - n_vals, remaining());
143-
if (ARROW_PREDICT_FALSE(n_last_vals > 0)) {
143+
if (n_last_vals > 0) {
144144
ARROW_DCHECK_LT(n_last_vals, 8);
145145
n_vals += GetBatchInByte(out.NewStartingAt(n_vals), n_last_vals);
146146
}
@@ -215,15 +215,15 @@ class BitPackedRunToBitmapDecoder {
215215
/// Return how much the decoder would advance if asked to.
216216
///
217217
/// Does not modify input.
218-
rle_size_t AdvanceCapacity(rle_size_t batch_size) const noexcept {
218+
rle_size_t GetAdvanceCapacity(rle_size_t batch_size) const noexcept {
219219
const auto n_vals = std::min(batch_size, remaining());
220220
return n_vals;
221221
}
222222

223223
/// Advance by as many values as provided or until exhaustion of the decoder.
224224
/// Return the number of values skipped.
225225
[[nodiscard]] rle_size_t Advance(rle_size_t batch_size) {
226-
const auto n_vals = AdvanceCapacity(batch_size);
226+
const auto n_vals = GetAdvanceCapacity(batch_size);
227227
values_read_ += n_vals;
228228
ARROW_DCHECK_GE(remaining(), 0);
229229
return n_vals;
@@ -236,7 +236,7 @@ class BitPackedRunToBitmapDecoder {
236236
/// May write fewer elements to the output than requested if there are not enough values
237237
/// left.
238238
[[nodiscard]] rle_size_t GetBatch(BitmapSpanMut out, rle_size_t batch_size) {
239-
auto n_vals = AdvanceCapacity(batch_size);
239+
auto n_vals = GetAdvanceCapacity(batch_size);
240240
arrow::internal::CopyBitmap(unread_values_ptr(), unread_values_bit_offset(), n_vals,
241241
out.data(), out.bit_start());
242242
return Advance(n_vals);

cpp/src/arrow/util/rle_bitmap_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ TEST_P(RleRunToBitmapDecoderTest, Decode) {
315315

316316
INSTANTIATE_TEST_SUITE_P( //
317317
RleBitmap, RleRunToBitmapDecoderTest,
318-
::testing::Values(0, 1, 3, 8, 9, 13, 64, 100, 100, 1000));
318+
::testing::Values(0, 1, 3, 8, 9, 13, 64, 100, 177));
319319

320320
/*********************************
321321
* BitPackedRunToBitmapDecoder *
@@ -454,7 +454,7 @@ void CheckRleBitPackedToBitmap(const std::vector<uint8_t>& bytes,
454454
ASSERT_GT(n_vals, 0);
455455
for (const rle_size_t chunk_size :
456456
{rle_size_t{1}, rle_size_t{3}, rle_size_t{7}, rle_size_t{8}, rle_size_t{9},
457-
rle_size_t{33}, n_vals}) {
457+
rle_size_t{33}, n_vals, n_vals + 1}) {
458458
CheckRleBitPackedDecode(bytes, expected, chunk_size);
459459
// A non-zero output offset forces the first run to start at a non-byte
460460
// aligned output position.

0 commit comments

Comments
 (0)