pub struct SegmentKey {
pub start_frame_no: u64,
pub end_frame_no: u64,
pub timestamp: u64,
}
Expand description
SegmentKey is used to index segment data, where keys a lexicographically ordered.
The scheme is {u64::MAX - start_frame_no}-{u64::MAX - end_frame_no}
. With that naming convention, when looking for
the segment containing ‘n’, we can perform a prefix search with “{u64::MAX - n}”. The first
element of the range will be the biggest segment that contains n if it exists.
Beware that if no segments contain n, either the smallest segment not containing n, if n < argmin
{start_frame_no}, or the largest segment if n > argmax {end_frame_no} will be returned.
e.g:
ⓘ
let mut map = BTreeMap::new();
let meta = SegmentMeta { start_frame_no: 1, end_frame_no: 100 };
map.insert(SegmentKey(&meta).to_string(), meta);
let meta = SegmentMeta { start_frame_no: 101, end_frame_no: 500 };
map.insert(SegmentKey(&meta).to_string(), meta);
let meta = SegmentMeta { start_frame_no: 101, end_frame_no: 1000 };
map.insert(SegmentKey(&meta).to_string(), meta);
map.range(format!("{:020}", u64::MAX - 50)..).next();
map.range(format!("{:020}", u64::MAX - 0)..).next();
map.range(format!("{:020}", u64::MAX - 1)..).next();
map.range(format!("{:020}", u64::MAX - 100)..).next();
map.range(format!("{:020}", u64::MAX - 101)..).next();
map.range(format!("{:020}", u64::MAX - 5000)..).next();
Fields§
§start_frame_no: u64
§end_frame_no: u64
§timestamp: u64
Trait Implementations§
Source§impl Clone for SegmentKey
impl Clone for SegmentKey
Source§fn clone(&self) -> SegmentKey
fn clone(&self) -> SegmentKey
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SegmentKey
impl Debug for SegmentKey
Source§impl Display for SegmentKey
impl Display for SegmentKey
Source§impl From<&SegmentMeta> for SegmentKey
impl From<&SegmentMeta> for SegmentKey
Source§fn from(value: &SegmentMeta) -> Self
fn from(value: &SegmentMeta) -> Self
Converts to this type from the input type.
Source§impl FromStr for SegmentKey
impl FromStr for SegmentKey
Source§impl Ord for SegmentKey
impl Ord for SegmentKey
Source§impl PartialEq for SegmentKey
impl PartialEq for SegmentKey
Source§impl PartialOrd for SegmentKey
impl PartialOrd for SegmentKey
impl Copy for SegmentKey
impl Eq for SegmentKey
impl StructuralPartialEq for SegmentKey
Auto Trait Implementations§
impl Freeze for SegmentKey
impl RefUnwindSafe for SegmentKey
impl Send for SegmentKey
impl Sync for SegmentKey
impl Unpin for SegmentKey
impl UnwindSafe for SegmentKey
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.