src/persy.rs
changed.
src/index/config.rs
changed.
628 | 628 | Ok(SegmentRawIter::new(segment, self.address.scan(segment)?, read_snapshot)) |
|
629 | 629 | } |
|
630 | 630 | ||
631 | + | pub fn scan_snapshot_index(&self, segment_id: SegmentId, snapshot: SnapshotId) -> PRes<SegmentSnapshotRawIter> { |
|
632 | + | let res = if let Some(r) = self.snapshots.scan(snapshot, segment_id)? { |
|
633 | + | r |
|
634 | + | } else { |
|
635 | + | self.address.scan(segment_id)? |
|
636 | + | }; |
|
637 | + | Ok(SegmentSnapshotRawIter::new(segment_id, res, snapshot)) |
|
638 | + | } |
|
639 | + | ||
631 | 640 | pub fn scan_snapshot(&self, segment_id: SegmentId, snapshot: SnapshotId) -> PRes<SegmentSnapshotRawIter> { |
|
632 | 641 | let res = self.snapshots.scan(snapshot, segment_id)?.unwrap(); |
|
633 | 642 | Ok(SegmentSnapshotRawIter::new(segment_id, res, snapshot)) |
745 | 754 | K: IndexType, |
|
746 | 755 | V: IndexType, |
|
747 | 756 | { |
|
748 | - | let read_snapshot = self.snapshot()?; |
|
757 | + | let read_snapshot = self.snapshots.read_snapshot()?; |
|
749 | 758 | let r = self.get_snapshot(index_id, read_snapshot, k); |
|
750 | 759 | release_snapshot(read_snapshot, &self.snapshots, &self.allocator, &self.journal)?; |
|
751 | 760 | r |
791 | 800 | V: IndexType, |
|
792 | 801 | R: RangeBounds<K>, |
|
793 | 802 | { |
|
794 | - | let read_snapshot = self.snapshot()?; |
|
803 | + | let read_snapshot = self.snapshots.read_snapshot()?; |
|
795 | 804 | self.range_snapshot(index_id, read_snapshot, range, true) |
|
796 | 805 | } |
|
797 | 806 |
847 | 856 | release_snapshot(snapshot, &self.snapshots, &self.allocator, &self.journal)?; |
|
848 | 857 | res |
|
849 | 858 | } |
|
859 | + | ||
850 | 860 | pub fn list_indexes_snapshot(&self, snapshot: SnapshotId) -> PRes<Vec<(String, IndexInfo)>> { |
|
851 | 861 | let list = self.snapshots.list(snapshot)?; |
|
852 | 862 | list.into_iter() |
386 | 386 | ||
387 | 387 | pub fn get_index(p: &PersyImpl, snapshot_id: SnapshotId, index_id: &IndexId) -> PRes<IndexConfig> { |
|
388 | 388 | let segment_meta = index_id_to_segment_id_meta(index_id); |
|
389 | - | p.scan_snapshot(segment_meta, snapshot_id) |
|
389 | + | p.scan_snapshot_index(segment_meta, snapshot_id) |
|
390 | 390 | .map_err(error_map)? |
|
391 | 391 | .next(p) |
|
392 | 392 | .map(|(_, content)| IndexConfig::deserialize(&mut Cursor::new(content))) |