Restore from a checkpoint snapshot.
(snap: PayloadIndexSetSnapshot)
| 441 | |
| 442 | /// Restore from a checkpoint snapshot. |
| 443 | pub fn from_snapshot(snap: PayloadIndexSetSnapshot) -> Self { |
| 444 | let mut indexes = HashMap::new(); |
| 445 | for idx_snap in snap.indexes { |
| 446 | let mut bitmaps = PayloadIndexBitmaps::for_kind(idx_snap.kind); |
| 447 | for (key_bytes, bm_bytes) in idx_snap.entries { |
| 448 | let Ok(key) = zerompk::from_msgpack::<PayloadKey>(&key_bytes) else { |
| 449 | continue; |
| 450 | }; |
| 451 | let Ok(bm) = RoaringBitmap::deserialize_from(bm_bytes.as_slice()) else { |
| 452 | continue; |
| 453 | }; |
| 454 | *bitmaps.entry_or_default(key) = bm; |
| 455 | } |
| 456 | let idx = PayloadIndex { |
| 457 | field: idx_snap.field.clone(), |
| 458 | kind: idx_snap.kind, |
| 459 | bitmaps, |
| 460 | }; |
| 461 | indexes.insert(idx_snap.field, idx); |
| 462 | } |
| 463 | Self { indexes } |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | // ── Tests ───────────────────────────────────────────────────────────────────── |
nothing calls this directly
no test coverage detected