1use std::path::Path;
12
13use crate::DevError;
14
15pub fn rebuild_offline(data_dir: &Path) -> Result<(), DevError> {
18 let o_path = waratah_storage::hexastore_data_dir(
19 data_dir,
20 waratah_storage::MAIN_REPOSITORY_ID,
21 waratah_storage::PartitionAxis::O,
22 );
23 if !o_path.exists() {
24 return Err(DevError::TemporalRebuild(format!(
25 "no O store at {}",
26 o_path.display()
27 )));
28 }
29 let storage =
30 waratah_storage::Storage::open_rocksdb(&o_path, waratah_storage::PartitionAxis::O)?;
31 let stats = std::sync::Mutex::new(waratah_stats::ShardStats::memory());
32 let posted = waratah_partition::rebuild_temporal_index_storage(
33 &storage,
34 &stats,
35 waratah_temporal::ingest_coverer_config(),
36 )
37 .map_err(|error| DevError::TemporalRebuild(error.to_string()))?;
38 let epoch = storage.temporal_index_epoch()?.unwrap_or(0);
39 println!("temporal rebuild-index: {posted} postings, epoch {epoch}");
40 Ok(())
41}