AntoinePrv commented on code in PR #50422:
URL: https://github.com/apache/arrow/pull/50422#discussion_r3550170599


##########
cpp/src/arrow/util/rle_encoding_internal.h:
##########
@@ -515,6 +573,71 @@ class RleBitPackedDecoder {
                                      int64_t valid_bits_offset, rle_size_t 
null_count);
 };
 
+/// Minimal decoder for legacy bit packed encoding (BIT_PACKED = 4).
+///
+/// The number of values that the decoder can represent is up to 2^31 - 1.
+template <typename T>
+class BitPackedDecoder : private BitPackedRunDecoder<T> {
+ private:
+  using Base = BitPackedRunDecoder<T>;
+
+ public:
+  /// The type in which the data should be decoded.
+  using value_type = T;
+
+  using Base::Advance;
+
+  BitPackedDecoder() noexcept = default;
+
+  /// Create a decoder object.
+  ///
+  /// data and data_size are the raw bytes to decode.
+  /// value_bit_width is the size in bits of each encoded value.
+  BitPackedDecoder(const uint8_t* data, rle_size_t data_size,
+                   rle_size_t value_bit_width) noexcept {
+    Reset(data, data_size, value_bit_width);
+  }
+
+  void Reset(const uint8_t* data, rle_size_t data_size,
+             rle_size_t value_bit_width) noexcept {
+    value_bit_width_ = value_bit_width;
+    const auto value_count = (static_cast<int64_t>(data_size) * 8) / 
value_bit_width;
+    ARROW_DCHECK_LE(value_count, std::numeric_limits<rle_size_t>::max());

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to