Skip to content

Commit

Permalink
More shale cleanups (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Nov 1, 2023
1 parent 28665e4 commit 3718962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion shale/src/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl<M: CachedStore> CompactSpaceInner<M> {
.unwrap();

if desc_addr != DiskAddress(**self.header.meta_space_tail) {
let desc_last = self.get_descriptor(**self.header.meta_space_tail.value)?;
let desc_last = self.get_descriptor(*self.header.meta_space_tail.value)?;
let mut desc = self.get_descriptor(desc_addr)?;
desc.write(|r| *r = *desc_last).unwrap();
let mut header = self.get_header(desc.haddr.into())?;
Expand Down
21 changes: 8 additions & 13 deletions shale/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub trait CachedStore: Debug + Send + Sync {
/// . Users of [ShaleStore] implementation, however, will only use [ObjRef] for safeguarded access.
#[derive(Debug)]
pub struct Obj<T: Storable> {
value: Box<StoredView<T>>,
value: StoredView<T>,
dirty: Option<u64>,
}

Expand All @@ -109,7 +109,7 @@ impl<T: Storable> Obj<T> {
DiskAddress(NonZeroUsize::new(self.value.get_offset()))
}

/// Write to the underlying object. Returns `Some(())` on success.
/// Write to the underlying object. Returns `Ok(())` on success.
#[inline]
pub fn write(&mut self, modify: impl FnOnce(&mut T)) -> Result<(), ObjWriteError> {
modify(self.value.write());
Expand All @@ -129,7 +129,7 @@ impl<T: Storable> Obj<T> {
}

#[inline(always)]
pub fn from_typed_view(value: Box<StoredView<T>>) -> Self {
pub fn from_typed_view(value: StoredView<T>) -> Self {
Obj { value, dirty: None }
}

Expand Down Expand Up @@ -341,11 +341,11 @@ impl<T: Storable + 'static> StoredView<T> {
ptr: DiskAddress,
len_limit: u64,
) -> Result<Obj<T>, ShaleError> {
Ok(Obj::from_typed_view(Box::new(Self::new(
Ok(Obj::from_typed_view(Self::new(
ptr.get(),
len_limit,
store,
)?)))
)?))
}

#[inline(always)]
Expand All @@ -355,9 +355,9 @@ impl<T: Storable + 'static> StoredView<T> {
len_limit: u64,
decoded: T,
) -> Result<Obj<T>, ShaleError> {
Ok(Obj::from_typed_view(Box::new(Self::from_hydrated(
Ok(Obj::from_typed_view(Self::from_hydrated(
addr, len_limit, decoded, store,
)?)))
)?))
}
}

Expand Down Expand Up @@ -390,12 +390,7 @@ impl<T: Storable> StoredView<T> {
error: "dirty write",
});
}
let r = Box::new(StoredView::new_from_slice(
addr_,
length,
decoded,
s.value.get_mem_store(),
)?);
let r = StoredView::new_from_slice(addr_, length, decoded, s.value.get_mem_store())?;
Ok(Obj {
value: r,
dirty: None,
Expand Down

0 comments on commit 3718962

Please sign in to comment.