Skip to content

Commit e942c17

Browse files
committed
Explicit little endian name
1 parent 46d948e commit e942c17

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

cpp/src/arrow/util/rle_bitmap_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class RleRunToBitmapDecoder
168168

169169
void Reset(const RunType& run) noexcept {
170170
values_left_ = run.values_count();
171-
if (run.value() == 0) {
171+
if (run.value_little_endian() == 0) {
172172
value_pattern_ = uint8_t{0};
173173
} else {
174174
value_pattern_ = uint8_t{0xFF};

cpp/src/arrow/util/rle_encoding_internal.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ class RleRun {
114114
std::copy(data, data + raw_data_size(value_bit_width), data_.begin());
115115
}
116116

117-
/// The repeated value in the run
118-
uint64_t value() const noexcept { return SafeLoadAs<uint64_t>(data_.data()); }
117+
/// The repeated value in the run in little endian form (as stored in the buffer).
118+
uint64_t value_little_endian() const noexcept {
119+
// Underlying memcpy is required to avoid undefined behavior.
120+
return SafeLoadAs<uint64_t>(data_.data());
121+
}
119122

120123
/// The number of repeated values in this run.
121124
constexpr rle_size_t values_count() const noexcept { return values_count_; }
@@ -278,10 +281,8 @@ class RleRunDecoder {
278281
// if the bool value isn't 0 or 1.
279282
value_ = *run.raw_data_ptr() & 1;
280283
} else {
281-
// Memcopy is required to avoid undefined behavior.
282-
value_ = {};
283-
std::memcpy(&value_, run.raw_data_ptr(), run.raw_data_size(value_bit_width));
284-
value_ = ::arrow::bit_util::FromLittleEndian(value_);
284+
value_ = static_cast<value_type>(
285+
::arrow::bit_util::FromLittleEndian(run.value_little_endian()));
285286
}
286287
}
287288

0 commit comments

Comments
 (0)