MCPcopy Create free account
hub / github.com/apache/arrow / RleRun

Class RleRun

cpp/src/arrow/util/rle_encoding_internal.h:105–142  ·  view source on GitHub ↗

A Single Run Length Encoded run. Consist of a single value repeated multiple times. A previous version of this class also stored the value bit width to be self contain, removing it and passing it explicitly when needed proved to speed up decoding up to 10 % on some benchmarks.

Source from the content-addressed store, hash-verified

103/// removing it and passing it explicitly when needed proved to speed up decoding up to
104/// 10 % on some benchmarks.
105class RleRun {
106 public:
107 constexpr RleRun() noexcept = default;
108
109 explicit RleRun(const uint8_t* data, rle_size_t values_count,
110 rle_size_t value_bit_width) noexcept
111 : values_count_(values_count) {
112 ARROW_DCHECK_GE(value_bit_width, 0);
113 ARROW_DCHECK_GE(values_count, 0);
114 std::copy(data, data + raw_data_size(value_bit_width), data_.begin());
115 }
116
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 }
122
123 /// The number of repeated values in this run.
124 constexpr rle_size_t values_count() const noexcept { return values_count_; }
125
126 /// A pointer to the repeated value raw bytes.
127 constexpr const uint8_t* raw_data_ptr() const noexcept { return data_.data(); }
128
129 /// The number of bytes used for the raw repeated value.
130 constexpr rle_size_t raw_data_size(rle_size_t value_bit_width) const noexcept {
131 auto out = bit_util::BytesForBits(value_bit_width);
132 ARROW_DCHECK_LE(out, std::numeric_limits<rle_size_t>::max());
133 return static_cast<rle_size_t>(out);
134 }
135
136 private:
137 /// The repeated value raw bytes stored inside the class with enough space to store
138 /// up to a 64 bit value.
139 alignas(8) std::array<uint8_t, 8> data_ = {};
140 /// The number of time the value is repeated.
141 rle_size_t values_count_ = 0;
142};
143
144template <typename T>
145class BitPackedRunDecoder;

Callers 4

TEST_PFunction · 0.85
TESTFunction · 0.85
TestRleDecoderFunction · 0.85
PeekImplMethod · 0.85

Calls

no outgoing calls

Tested by 3

TEST_PFunction · 0.68
TESTFunction · 0.68
TestRleDecoderFunction · 0.68