From 7f481f8f18802831c7495e349663ccd07a851d3b Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Tue, 26 Mar 2024 10:36:11 -0400 Subject: [PATCH] tweak descriptor method names (#614) --- firewood/src/shale/compact.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/firewood/src/shale/compact.rs b/firewood/src/shale/compact.rs index d661333ef..31e89b589 100644 --- a/firewood/src/shale/compact.rs +++ b/firewood/src/shale/compact.rs @@ -300,10 +300,6 @@ impl From> for StoreInner { } impl StoreInner { - fn get_descriptor(&self, ptr: DiskAddress) -> Result, ShaleError> { - StoredView::ptr_to_obj(&self.meta_store, ptr, ChunkDescriptor::SERIALIZED_LEN) - } - fn get_data_ref( &self, ptr: DiskAddress, @@ -320,7 +316,11 @@ impl StoreInner { self.get_data_ref::(ptr, ChunkFooter::SERIALIZED_LEN) } - fn del_desc(&mut self, desc_addr: DiskAddress) -> Result<(), ShaleError> { + fn get_descriptor(&self, ptr: DiskAddress) -> Result, ShaleError> { + StoredView::ptr_to_obj(&self.meta_store, ptr, ChunkDescriptor::SERIALIZED_LEN) + } + + fn delete_descriptor(&mut self, desc_addr: DiskAddress) -> Result<(), ShaleError> { let desc_size = ChunkDescriptor::SERIALIZED_LEN; // TODO: subtracting two disk addresses is only used here, probably can rewrite this // debug_assert!((desc_addr.0 - self.header.base_addr.value.into()) % desc_size == 0); @@ -343,7 +343,7 @@ impl StoreInner { Ok(()) } - fn new_desc(&mut self) -> Result { + fn new_descriptor_address(&mut self) -> Result { let addr = **self.header.meta_store_tail; #[allow(clippy::unwrap_used)] self.header @@ -379,7 +379,7 @@ impl StoreInner { h = offset; chunk_size += ChunkHeader::SERIALIZED_LEN + ChunkFooter::SERIALIZED_LEN + pheader_chunk_size; - self.del_desc(pheader_desc_addr)?; + self.delete_descriptor(pheader_desc_addr)?; } } @@ -406,11 +406,11 @@ impl StoreInner { } chunk_size += ChunkHeader::SERIALIZED_LEN + ChunkFooter::SERIALIZED_LEN + nheader_chunk_size; - self.del_desc(nheader_desc_addr)?; + self.delete_descriptor(nheader_desc_addr)?; } } - let desc_addr = self.new_desc()?; + let desc_addr = self.new_descriptor_address()?; { let mut desc = self.get_descriptor(desc_addr)?; #[allow(clippy::unwrap_used)] @@ -468,7 +468,7 @@ impl StoreInner { #[allow(clippy::unwrap_used)] header.modify(|h| h.is_freed = false).unwrap(); } - self.del_desc(ptr)?; + self.delete_descriptor(ptr)?; true } else if chunk_size > length as usize + HEADER_SIZE + FOOTER_SIZE { // able to split @@ -495,7 +495,7 @@ impl StoreInner { let offset = desc_haddr + HEADER_SIZE + length as usize + FOOTER_SIZE; let rchunk_size = chunk_size - length as usize - FOOTER_SIZE - HEADER_SIZE; - let rdesc_addr = self.new_desc()?; + let rdesc_addr = self.new_descriptor_address()?; { let mut rdesc = self.get_descriptor(rdesc_addr)?; #[allow(clippy::unwrap_used)] @@ -525,7 +525,7 @@ impl StoreInner { .modify(|f| f.chunk_size = rchunk_size as u64) .unwrap(); } - self.del_desc(ptr)?; + self.delete_descriptor(ptr)?; true } else { false