Skip to content

Commit

Permalink
tweak descriptor method names (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Laine authored Mar 26, 2024
1 parent 80805dc commit 7f481f8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions firewood/src/shale/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ impl From<StoreInner<StoreRevMut>> for StoreInner<StoreRevShared> {
}

impl<M: LinearStore> StoreInner<M> {
fn get_descriptor(&self, ptr: DiskAddress) -> Result<Obj<ChunkDescriptor>, ShaleError> {
StoredView::ptr_to_obj(&self.meta_store, ptr, ChunkDescriptor::SERIALIZED_LEN)
}

fn get_data_ref<U: Storable + 'static>(
&self,
ptr: DiskAddress,
Expand All @@ -320,7 +316,11 @@ impl<M: LinearStore> StoreInner<M> {
self.get_data_ref::<ChunkFooter>(ptr, ChunkFooter::SERIALIZED_LEN)
}

fn del_desc(&mut self, desc_addr: DiskAddress) -> Result<(), ShaleError> {
fn get_descriptor(&self, ptr: DiskAddress) -> Result<Obj<ChunkDescriptor>, 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);
Expand All @@ -343,7 +343,7 @@ impl<M: LinearStore> StoreInner<M> {
Ok(())
}

fn new_desc(&mut self) -> Result<DiskAddress, ShaleError> {
fn new_descriptor_address(&mut self) -> Result<DiskAddress, ShaleError> {
let addr = **self.header.meta_store_tail;
#[allow(clippy::unwrap_used)]
self.header
Expand Down Expand Up @@ -379,7 +379,7 @@ impl<M: LinearStore> StoreInner<M> {
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)?;
}
}

Expand All @@ -406,11 +406,11 @@ impl<M: LinearStore> StoreInner<M> {
}
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)]
Expand Down Expand Up @@ -468,7 +468,7 @@ impl<M: LinearStore> StoreInner<M> {
#[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
Expand All @@ -495,7 +495,7 @@ impl<M: LinearStore> StoreInner<M> {

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)]
Expand Down Expand Up @@ -525,7 +525,7 @@ impl<M: LinearStore> StoreInner<M> {
.modify(|f| f.chunk_size = rchunk_size as u64)
.unwrap();
}
self.del_desc(ptr)?;
self.delete_descriptor(ptr)?;
true
} else {
false
Expand Down

0 comments on commit 7f481f8

Please sign in to comment.