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

Class RleRun

cpp/src/arrow/util/rle_encoding_internal.h:103–138  ·  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

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

Callers 3

TESTFunction · 0.85
TestRleDecoderFunction · 0.85
PeekImplMethod · 0.85

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.68
TestRleDecoderFunction · 0.68