You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tsfile.apache.org by "fl0-m (via GitHub)" <gi...@apache.org> on 2026/09/28 15:11:13 UTC
[I] [CPP] Table query returns 0 rows when the time range starts in a device's second chunk [tsfile]
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: dev-unsubscribe@tsfile.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [CPP] Table query returns 0 rows when the time range starts in a device's second chunk [tsfile]
Posted by Alan Chuang <al...@gmail.com>.
Thanks for the issue and the fix example. We have applied the patch.
On Thu, Oct 8, 2026 at 11:57 AM ColinLeeo (via GitHub) <gi...@apache.org>
wrote:
>
> ColinLeeo closed issue #972: [CPP] Table query returns 0 rows when the
> time range starts in a device's second chunk
> URL: https://github.com/apache/tsfile/issues/972
>
>
> --
> 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] Table query returns 0 rows when the time range starts in a device's second chunk [tsfile]
Posted by "ColinLeeo (via GitHub)" <gi...@apache.org>.
ColinLeeo commented on issue #972:
URL: https://github.com/apache/tsfile/issues/972#issuecomment-6051879355
Thanks for your issue and fix example. 👍
--
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] Table query returns 0 rows when the time range starts in a device's second chunk [tsfile]
Posted by "ColinLeeo (via GitHub)" <gi...@apache.org>.
ColinLeeo closed issue #972: [CPP] Table query returns 0 rows when the time range starts in a device's second chunk
URL: https://github.com/apache/tsfile/issues/972
--
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