| 372 | } |
| 373 | |
| 374 | void DataEngine::clearDatasetChunks(DatasetId dataset_id) { |
| 375 | // Like retireTopic, reclaim each topic's materialized chunks — but WITHOUT |
| 376 | // adding the ids to retired_topic_ids, so they stay in listTopics() and a refill |
| 377 | // writes back into them. For each live topic, clearChunks() empties the deque and |
| 378 | // resets the eviction floor + cached min/max + row count, so a DataReader reports |
| 379 | // an empty range immediately. Unknown dataset_id -> no-op; clearing an empty topic |
| 380 | // is a no-op (idempotent). |
| 381 | // |
| 382 | // clearChunks() FREES the deque, so hold the engine lock across the whole sweep |
| 383 | // (chunk-freeing mutation: GUI-thread-only, callers drop cached TopicChunk* first |
| 384 | // — same contract as retireTopic/enforceRetention). |
| 385 | auto lock = lockEngine(); |
| 386 | for (const TopicId topic_id : listTopicsLocked(dataset_id)) { |
| 387 | if (TopicStorage* storage = getTopicStorage(topic_id)) { |
| 388 | storage->clearChunks(); |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | DataEngine::DatasetChunkSnapshot DataEngine::detachDatasetChunks(DatasetId dataset_id) { |
| 394 | auto lock = lockEngine(); |