This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch iotdb in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit 86ae2396640493ccdc8fb7021b3d8e0afe293c15 Author: Hongzhi Gao <[email protected]> AuthorDate: Tue Jun 18 11:30:39 2024 +0800 fix ts2diff decoder (#118) --- cpp/src/encoding/ts2diff_decoder.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpp/src/encoding/ts2diff_decoder.h b/cpp/src/encoding/ts2diff_decoder.h index a07e1f47..8cdd7ca1 100644 --- a/cpp/src/encoding/ts2diff_decoder.h +++ b/cpp/src/encoding/ts2diff_decoder.h @@ -90,6 +90,9 @@ class TS2DIFFDecoder : public Decoder { bits_left_ -= bits; bits = 0; } + if (bits <= 0 && current_index_ == 0) { + break; + } read_byte_if_empty(in); } return value; @@ -128,12 +131,12 @@ int32_t TS2DIFFDecoder<int32_t>::decode(common::ByteStream &in) { current_index_ = 1; return ret_value; } - stored_value_ = (int32_t)read_long(bit_width_, in); - ret_value = stored_value_ + first_value_ + delta_min_; - first_value_ = ret_value; if (current_index_++ >= write_index_) { current_index_ = 0; } + stored_value_ = (int32_t)read_long(bit_width_, in); + ret_value = stored_value_ + first_value_ + delta_min_; + first_value_ = ret_value; return ret_value; }
