pub struct AllocatedRanges { /* private fields */ }
Expand description
AllocatedRanges tracks the logical ranges of a file which are pre-allocated using allocate, in other words, the ranges of the file with overwrite extents. It’s used by PagedObjectHandle to split writes to CoW ranges and writes to overwrite ranges into separate batches so they can have different transaction options.
It has a mutex on the list of ranges to make sure checking for overlaps and adding new ranges don’t collide. When getting an iterator of overlapping ranges, the lock is held until the iterator is dropped.
Implementations§
Source§impl AllocatedRanges
impl AllocatedRanges
pub fn new(ranges_to_apply: &[Range<u64>]) -> Self
pub fn clear(&self)
pub fn is_empty(&self) -> bool
Sourcepub fn overlap<'a>(&'a self, query_range: Range<u64>) -> RangeOverlapIter<'a>
pub fn overlap<'a>(&'a self, query_range: Range<u64>) -> RangeOverlapIter<'a>
Find the overlapping overwrite ranges in the given range for this file, so writes can be split between them appropriately. Ranges with RangeType::Overwrite should be written to with multi_overwrite and RangeType::Cow should use multi_write.
Note: The returned iterator holds a lock on the ranges until it’s dropped, so use it accordingly.
Sourcepub fn apply_range(&self, new_range: Range<u64>)
pub fn apply_range(&self, new_range: Range<u64>)
Apply range takes a single, valid file range and inserts it into the list of ranges it’s storing. This list of ranges, so it’s easy to insert and search, is kept sorted and merged, so that the list has no overlapping ranges.
pub fn apply_range_to(ranges: &mut Vec<Range<u64>>, new_range: Range<u64>)
Sourcepub fn truncate(&self, cutoff: u64) -> bool
pub fn truncate(&self, cutoff: u64) -> bool
For when a file is truncated. Drop any ranges past the cutoff point. If a range covers the cutoff point, it is modified to end at the cutoff.
Additionally, this returns true if there were previously tracked ranges but they were all completely removed by this truncate call. In this case, metadata for a file will need to be updated since there are no longer any overwrite ranges.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AllocatedRanges
impl !RefUnwindSafe for AllocatedRanges
impl Send for AllocatedRanges
impl Sync for AllocatedRanges
impl Unpin for AllocatedRanges
impl UnwindSafe for AllocatedRanges
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
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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