This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new d87e0094 fix ts2diff decoder (#118)
d87e0094 is described below
commit d87e00949d9441bf189c8cc54a1b3296afeb1eed
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;
}