hongzhi-gao opened a new pull request, #734:
URL: https://github.com/apache/tsfile/pull/734

   **Summary**  
   
   Align C++ aligned-model page sealing with the Java behavior and fix reader 
handling of null-only value pages so that Debug builds pass.
   
   **Problem**  
   1. In the aligned model, time and value pages did not seal together when any 
page hit capacity (point count or memory), unlike the Java implementation.  
   2. When time/value pages were sealed together, all-null value pages (zero 
value bytes) caused reader issues: `ValuePageData::init` rejected zero-sized 
value buffers, and chunk headers were not set when all pages were pre-sealed, 
leading to `byte_buffer.h` assertion `(offset + len) <= real_data_size_` in 
Debug.  
   3. The tree-model reader (`QDSWithoutTimeGenerator`) used the non–null-aware 
value read path; for columns with nulls this could read past the value buffer 
and trigger the same assertion in Debug (tests 
`AlignedSealSync_TimeMemoryFirst` and `AlignedSealSync_PointCountWithNulls`).
   
   **Solution**  
   1. **Aligned seal sync**: When any aligned page (time or value) hits 
`page_writer_max_point_num_` or `page_writer_max_memory_bytes_`, seal all time 
and value pages together (mirroring Java).  
   2. **All-null value pages**: Allow `value_buf_size_ == 0` in 
`ValuePageData::init`; add `get_total_write_count()` and use it in 
`has_current_page_data()` so pages with only nulls are sealed; in 
`end_encode_chunk` (time and value), set `chunk_header_.data_size_` and 
`num_of_pages_` when `num_of_pages_ > 0` so pre-sealed chunks are valid.  
   3. **Reader null handling**: In `QDSWithoutTimeGenerator::next()`, use the 
null-aware `read(&len, &is_null_val)` for value columns and call `set_value` 
only when `!is_null_val`, avoiding reads beyond the value buffer for null rows.
   
   **Testing**  
   - New unit tests: `AlignedSealSync_PointCountWithNulls` (time seals by point 
count, value has nulls), `AlignedSealSync_TimeMemoryFirst`, 
`AlignedSealSync_ValueMemoryFirst`.  
   ---


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