You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tsfile.apache.org by "jt2594838 (via GitHub)" <gi...@apache.org> on 2024/06/11 05:14:40 UTC

[I] [CPP] Fix TS_2Diff [tsfile]

jt2594838 opened a new issue, #104:
URL: https://github.com/apache/tsfile/issues/104

   It is reported that the implementation of the TS_2Diff decoder in TsFile-CPP will mistakenly skip one byte, resulting in a wrong decoding result.


-- 
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: dev-unsubscribe@tsfile.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [CPP] Fix TS_2Diff [tsfile]

Posted by "761417898 (via GitHub)" <gi...@apache.org>.
761417898 commented on issue #104:
URL: https://github.com/apache/tsfile/issues/104#issuecomment-2171224636

   https://github.com/apache/tsfile/pull/118
   
   The TS2Diff decoder reads an extra byte after processing each group of data(TS2DIFFEncoder.block_size_ = 128), causing the header of the next group of data to be misaligned.
   
   Here are the unit tests, and the encoder's output is also consistent with the output from Java.
   ```
   TEST_F(TS2DIFFEncoderTest, TestIntEncoding) {
       common::ByteStream out_stream(1024, common::MOD_TS2DIFF_OBJ, false);
       const int row_num = 10000;
       int32_t data[row_num];
       memset(data, 0, sizeof(int32_t) * row_num);
       for (int i = 0; i < row_num; i++) {
           data[i] = i * i;
       }
       
       for (int i = 0; i < row_num; i++) {
           EXPECT_EQ(encoder_int_->encode(data[i], out_stream), common::E_OK);
       }
       EXPECT_EQ(encoder_int_->flush(out_stream), common::E_OK);
   
       for (int i = 0; i < row_num; i++) {
           int32_t x;
           EXPECT_EQ(decoder_int_->read_int32(x, out_stream), common::E_OK);
           EXPECT_EQ(x, data[i]);
       }
   }
   
   TEST_F(TS2DIFFEncoderTest, TestLongEncoding) {
       common::ByteStream out_stream(1024, common::MOD_TS2DIFF_OBJ, false);
       const int row_num = 10000;
       int64_t data[row_num];
       memset(data, 0, sizeof(int64_t) * row_num);
       for (int i = 0; i < row_num; i++) {
           data[i] = i * i;
       }
       
       for (int i = 0; i < row_num; i++) {
           EXPECT_EQ(encoder_long_->encode(data[i], out_stream), common::E_OK);
       }
       EXPECT_EQ(encoder_long_->flush(out_stream), common::E_OK);
   
       for (int i = 0; i < row_num; i++) {
           int64_t x;
           EXPECT_EQ(decoder_long_->read_int64(x, out_stream), common::E_OK);
           EXPECT_EQ(x, data[i]);
       }
   }
   ```
   
   


-- 
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: dev-unsubscribe@tsfile.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [CPP] Fix TS_2Diff [tsfile]

Posted by "jt2594838 (via GitHub)" <gi...@apache.org>.
jt2594838 closed issue #104: [CPP] Fix TS_2Diff
URL: https://github.com/apache/tsfile/issues/104


-- 
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: dev-unsubscribe@tsfile.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org