| 354 | } |
| 355 | |
| 356 | pub fn build_from_raw( |
| 357 | raw: <Self as RawDeserialize>::Raw, |
| 358 | cache: &HNSWIndexCache, |
| 359 | dummy_bufman: &BufferManager, |
| 360 | pending_items: &mut FxHashMap<FileIndex<IndexFileId>, SharedNode>, |
| 361 | latest_version_links: &mut FxHashMap<FileOffset, SharedLatestNode>, |
| 362 | latest_version_links_cursor: u64, |
| 363 | ) -> Result<Self, BufIoError> { |
| 364 | let ( |
| 365 | hnsw_level, |
| 366 | version, |
| 367 | prop_value, |
| 368 | prop_metadata, |
| 369 | neighbors, |
| 370 | parent_offset, |
| 371 | child_offset, |
| 372 | ) = raw; |
| 373 | |
| 374 | let parent = if parent_offset.0 != u32::MAX { |
| 375 | match latest_version_links.entry(parent_offset) { |
| 376 | Entry::Occupied(entry) => *entry.get(), |
| 377 | Entry::Vacant(entry) => { |
| 378 | let file_index = SharedLatestNode::deserialize_raw( |
| 379 | dummy_bufman, // not used |
| 380 | &cache.latest_version_links_bufman, |
| 381 | u64::MAX, // not used |
| 382 | latest_version_links_cursor, |
| 383 | parent_offset, |
| 384 | IndexFileId::invalid(), |
| 385 | cache, |
| 386 | )?; |
| 387 | let item = cache |
| 388 | .registry |
| 389 | .get(&HNSWIndexCache::combine_index(&file_index)) |
| 390 | .unwrap_or_else(|| { |
| 391 | *pending_items |
| 392 | .entry(file_index) |
| 393 | .or_insert_with(|| LazyItem::new_pending(file_index)) |
| 394 | }); |
| 395 | let ptr = LatestNode::new(item, parent_offset); |
| 396 | entry.insert(ptr); |
| 397 | ptr |
| 398 | } |
| 399 | } |
| 400 | } else { |
| 401 | ptr::null_mut() |
| 402 | }; |
| 403 | |
| 404 | let child = if child_offset.0 != u32::MAX { |
| 405 | match latest_version_links.entry(child_offset) { |
| 406 | Entry::Occupied(entry) => *entry.get(), |
| 407 | Entry::Vacant(entry) => { |
| 408 | let file_index = SharedLatestNode::deserialize_raw( |
| 409 | dummy_bufman, // not used |
| 410 | &cache.latest_version_links_bufman, |
| 411 | u64::MAX, // not used |
| 412 | latest_version_links_cursor, |
| 413 | child_offset, |