fl0-m opened a new issue, #972:
URL: https://github.com/apache/tsfile/issues/972

   **Version:** apache/tsfile `cpp`, commit 7ca2e79 (and `develop` 83fe559, 
same code). Files written by IoTDB 2.0.11 (table model, aligned).
   
   **What happens.** `TsFileSeriesScanIterator::init_chunk_reader_multi` loads 
the device's FIRST chunk without looking at the time filter. The first 
`get_next` then calls `get_next_page` on that chunk; when none of its rows is 
in the time range it returns `E_OK` with an **empty** TsBlock, and `get_next` 
returns that as a success. The table reader treats an empty block as the end of 
the series, so a query whose time range starts in a later chunk of the file 
returns 0 rows.
   
   **Reproduction.** Any IoTDB file whose device has ≥ 2 chunks (e.g. after one 
inner compaction). Query the table with `start_time` at the middle of the 
device's time range: 0 rows are returned; without a time filter, or with a 
start inside the first chunk, the rows are there. On a real file (one device, 2 
chunks, 23,751 rows) a start at 50 % of the range returned 0 of 11,666 rows and 
at 75 % 0 of 5,809.
   
   **Fix that works for us** (in `TsFileSeriesScanIterator::get_next`, after 
the `E_NO_MORE_DATA` with rows check):
   ```cpp
   if (IS_SUCC(ret) && ret_tsblock != nullptr && ret_tsblock->get_row_count() 
== 0) {
       if (chunk_reader_->has_more_data()) continue;          // next page of 
this chunk
       if (has_next_chunk()) { force_load_next_chunk = true; continue; }  // 
next chunk
       return common::E_NO_MORE_DATA;
   }
   ```
   With it, 1,490 of 1,490 time windows over 60 real files equalled a read 
without a time filter (count and sum).
   


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