Skip to content

fix cpp restore statistic#784

Merged
hongzhi-gao merged 4 commits into
apache:developfrom
hongzhi-gao:fix/cpp-restore-stat
Apr 20, 2026
Merged

fix cpp restore statistic#784
hongzhi-gao merged 4 commits into
apache:developfrom
hongzhi-gao:fix/cpp-restore-stat

Conversation

@hongzhi-gao
Copy link
Copy Markdown
Contributor

@hongzhi-gao hongzhi-gao commented Apr 17, 2026

问题

  1. RestorableTsFileIOWriter 在恢复 aligned value chunk 统计时,未结合 value page 的 null-bitmap 过滤空值位置,导致空值位也被错误参与统计更新。
  2. 恢复写入时只恢复了 schema,没恢复每个设备已经写到的最大时间戳状态

修复内容

  1. 修改 cpp/src/file/restorable_tsfile_io_writer.cc. 在恢复 aligned value page 时解析 num_values + null-bitmap按 bitmap 判断当前时间位是否有值,仅对非空位执行 value 解码和统计更新
  2. 在 MeasurementSchemaGroup 增加设备级 last_time_(初始 INT64_MIN)。恢复初始化(TsFileWriter::init(RestorableTsFileIOWriter*)) 时:遍历恢复出的 ChunkMeta,从统计信息 end_time_ 回填该设备 last_time_

English Version

Issues

  1. In RestorableTsFileIOWriter, aligned value-chunk statistics recovery did not correctly account for the value-page null bitmap, so null positions could be mistakenly included in statistic updates.
  2. During recovery append, only schema was restored; the per-device maximum written timestamp state was not restored.

Fixes

  1. Updated cpp/src/file/restorable_tsfile_io_writer.cc:

    • When recovering aligned value pages, parse num_values + null-bitmap.
    • Use the bitmap to determine whether each timestamp position actually has a value.
    • Decode value data and update statistics only for non-null positions.
  2. Added device-level last_time_ to MeasurementSchemaGroup (initialized to INT64_MIN):

    • In recovery initialization (TsFileWriter::init(RestorableTsFileIOWriter*)), iterate recovered ChunkMeta entries.
    • Rebuild each device’s last_time_ from chunk statistics (end_time_).

@hongzhi-gao hongzhi-gao merged commit a58a073 into apache:develop Apr 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant