(root_path: PathBuf)
| 367 | } |
| 368 | |
| 369 | pub fn deserialize(root_path: PathBuf) -> Result<Self, BufIoError> { |
| 370 | let dim_file = OpenOptions::new() |
| 371 | .read(true) |
| 372 | .write(true) |
| 373 | .create(true) |
| 374 | .truncate(false) |
| 375 | .open(root_path.join("index-tree.dim"))?; |
| 376 | let node_size = TFIDFIndexNode::get_serialized_size(); |
| 377 | let dim_bufman = Arc::new(BufferManager::new(dim_file, node_size as usize * 1000)?); |
| 378 | let offset_counter = AtomicU32::new(dim_bufman.file_size() as u32); |
| 379 | let data_bufmans = Arc::new(BufferManagerFactory::new( |
| 380 | root_path.clone().into(), |
| 381 | |root, version: &VersionNumber| root.join(format!("{}.idat", **version)), |
| 382 | 8192, |
| 383 | )); |
| 384 | let cache = TFIDFIndexCache::new(dim_bufman, data_bufmans, offset_counter); |
| 385 | let root = TFIDFIndexNode::deserialize( |
| 386 | &cache.dim_bufman, |
| 387 | &cache.data_bufmans, |
| 388 | FileOffset(4), |
| 389 | VersionNumber::from(u32::MAX), // not used |
| 390 | &cache, |
| 391 | )?; |
| 392 | let cursor = cache.dim_bufman.open_cursor()?; |
| 393 | let total_documents_count = AtomicU32::new(cache.dim_bufman.read_u32_with_cursor(cursor)?); |
| 394 | cache.dim_bufman.close_cursor(cursor)?; |
| 395 | |
| 396 | Ok(Self { |
| 397 | root, |
| 398 | cache, |
| 399 | total_documents_count, |
| 400 | }) |
| 401 | } |
| 402 | } |
nothing calls this directly
no test coverage detected