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.
| 101 | /// removing it and passing it explicitly when needed proved to speed up decoding up to |
| 102 | /// 10 % on some benchmarks. |
| 103 | class 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 | |
| 140 | template <typename T> |
| 141 | class BitPackedRunDecoder; |
no outgoing calls