Returns an L2_table of cluster addresses, only used for debugging.
(&mut self, l1_index: usize)
| 816 | |
| 817 | /// Returns an L2_table of cluster addresses, only used for debugging. |
| 818 | pub fn l2_table(&mut self, l1_index: usize) -> BlockResult<Option<&[u64]>> { |
| 819 | let l2_addr_disk = *self |
| 820 | .l1_table |
| 821 | .get(l1_index) |
| 822 | .ok_or_else(|| BlockError::new(BlockErrorKind::OutOfBounds, Error::InvalidIndex))?; |
| 823 | |
| 824 | if l2_addr_disk == 0 { |
| 825 | // Reading from an unallocated cluster will return zeros. |
| 826 | return Ok(None); |
| 827 | } |
| 828 | |
| 829 | if !self.l2_cache.contains_key(l1_index) { |
| 830 | // Not in the cache. |
| 831 | let table = VecCache::from_vec( |
| 832 | Self::read_l2_cluster(&mut self.raw_file, l2_addr_disk) |
| 833 | .map_err(|e| BlockError::new(BlockErrorKind::Io, Error::ReadingPointers(e)))?, |
| 834 | ); |
| 835 | let l1_table = &self.l1_table; |
| 836 | let raw_file = &mut self.raw_file; |
| 837 | self.l2_cache |
| 838 | .insert(l1_index, table, |index, evicted| { |
| 839 | raw_file.write_pointer_table_direct(l1_table[index], evicted.iter()) |
| 840 | }) |
| 841 | .map_err(|e| BlockError::new(BlockErrorKind::Io, Error::EvictingCache(e)))?; |
| 842 | } |
| 843 | |
| 844 | // The index must exist as it was just inserted if it didn't already. |
| 845 | Ok(Some(self.l2_cache.get(l1_index).unwrap().get_values())) |
| 846 | } |
| 847 | |
| 848 | /// Returns the refcount table for this file. This is only useful for debugging. |
| 849 | pub fn ref_table(&self) -> &[u64] { |
nothing calls this directly
no test coverage detected