pub struct CacheObject {
pub offset: usize,
pub crc32: u32,
pub data_decompressed: Vec<u8>,
pub mem_recorder: Option<Arc<AtomicUsize>>,
pub is_delta_in_pack: bool,
/* private fields */
}Expand description
Represents a cached object in memory, which may be a delta or a base object.
Fields§
§offset: usize§crc32: u32§data_decompressed: Vec<u8>§mem_recorder: Option<Arc<AtomicUsize>>§is_delta_in_pack: boolImplementations§
Source§impl CacheObject
impl CacheObject
Sourcepub fn new_for_undeltified(
obj_type: ObjectType,
data: Vec<u8>,
offset: usize,
crc32: u32,
) -> Self
pub fn new_for_undeltified( obj_type: ObjectType, data: Vec<u8>, offset: usize, crc32: u32, ) -> Self
Create a new CacheObject which is neither ObjectType::OffsetDelta nor ObjectType::HashDelta.
Sourcepub fn object_type(&self) -> ObjectType
pub fn object_type(&self) -> ObjectType
Get the ObjectType of the object.
Sourcepub fn base_object_hash(&self) -> Option<ObjectHash>
pub fn base_object_hash(&self) -> Option<ObjectHash>
Get the ObjectHash hash of the object.
If the object is a delta object, return None.
Sourcepub fn offset_delta(&self) -> Option<usize>
pub fn offset_delta(&self) -> Option<usize>
Get the offset delta of the object.
If the object is not an offset delta, return None.
Sourcepub fn hash_delta(&self) -> Option<ObjectHash>
pub fn hash_delta(&self) -> Option<ObjectHash>
Get the hash delta of the object.
If the object is not a hash delta, return None.
Sourcepub fn to_entry_metadata(&self) -> MetaAttached<Entry, EntryMeta>
pub fn to_entry_metadata(&self) -> MetaAttached<Entry, EntryMeta>
transform the CacheObject to MetaAttached<Entry, EntryMeta>
Trait Implementations§
Source§impl Clone for CacheObject
impl Clone for CacheObject
Source§impl Debug for CacheObject
impl Debug for CacheObject
Source§impl<'de> Deserialize<'de> for CacheObject
impl<'de> Deserialize<'de> for CacheObject
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Drop for CacheObject
impl Drop for CacheObject
Source§impl HeapSize for CacheObject
impl HeapSize for CacheObject
Source§fn heap_size(&self) -> usize
fn heap_size(&self) -> usize
If a CacheObject is ObjectType::HashDelta or ObjectType::OffsetDelta,
it will expand to another CacheObject of other types. To prevent potential OOM,
we record the size of the expanded object as well as that of the object itself.
Base objects, i.e., ObjectType::Blob, ObjectType::Tree, ObjectType::Commit,
and ObjectType::Tag, will not be expanded, so the heap-size of the object is the same
as the size of the data.
See Comment in PR #755 for more details.
Source§fn heap_size_sum_iter<'item, Fun, Iter>(make_iter: Fun) -> usize
fn heap_size_sum_iter<'item, Fun, Iter>(make_iter: Fun) -> usize
Source§fn heap_size_sum_exact_size_iter<'item, Fun, Iter>(make_iter: Fun) -> usizewhere
Self: 'item,
Fun: Fn() -> Iter,
Iter: ExactSizeIterator<Item = &'item Self>,
fn heap_size_sum_exact_size_iter<'item, Fun, Iter>(make_iter: Fun) -> usizewhere
Self: 'item,
Fun: Fn() -> Iter,
Iter: ExactSizeIterator<Item = &'item Self>,
Source§impl MemSizeRecorder for CacheObject
impl MemSizeRecorder for CacheObject
Source§fn record_mem_size(&self)
fn record_mem_size(&self)
record the mem-size of this CacheObj in a static var
since that, DO NOT modify CacheObj after recording
fn set_mem_recorder(&mut self, mem_recorder: Arc<AtomicUsize>)
Auto Trait Implementations§
impl Freeze for CacheObject
impl RefUnwindSafe for CacheObject
impl Send for CacheObject
impl Sync for CacheObject
impl Unpin for CacheObject
impl UnsafeUnpin for CacheObject
impl UnwindSafe for CacheObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more