jt2594838 commented on code in PR #764:
URL: https://github.com/apache/tsfile/pull/764#discussion_r3025466440


##########
cpp/src/encoding/int32_rle_decoder.h:
##########
@@ -125,8 +133,40 @@ class Int32RleDecoder : public Decoder {
         return result;
     }
 
-    int call_read_bit_packing_buffer(uint8_t header) {
-        int bit_packed_group_count = (int)(header >> 1);
+    int call_read_rle_run(uint32_t header_value) {
+        int ret = common::E_OK;
+        int run_length = (int)(header_value >> 1);
+        if (run_length <= 0) {
+            return common::E_DECODE_ERR;
+        }
+        int byte_width = (bit_width_ + 7) / 8;
+        // Read the repeated value (stored as byte_width bytes, little-endian)
+        int32_t value = 0;
+        for (int i = 0; i < byte_width; i++) {
+            uint8_t b;
+            if (RET_FAIL(common::SerializationUtil::read_ui8(b, byte_cache_))) 
{
+                return ret;
+            }
+            value |= ((int32_t)b) << (i * 8);
+        }
+        if (current_buffer_ != nullptr) {
+            common::mem_free(current_buffer_);
+        }
+        current_buffer_ = static_cast<int32_t*>(common::mem_alloc(
+            sizeof(int32_t) * run_length, common::MOD_DECODER_OBJ));
+        if (IS_NULL(current_buffer_)) {
+            return common::E_OOM;
+        }
+        for (int i = 0; i < run_length; i++) {
+            current_buffer_[i] = value;
+        }
+        current_count_ = run_length;
+        bitpacking_num_ = run_length;
+        return ret;

Review Comment:
   Is it possible to set a flag for RLE run, and we just store the repeated 
value instead of using current_buffer_?



-- 
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