Skip to main content

PriorityEntry

Struct PriorityEntry 

Source
pub struct PriorityEntry<K, V> {
    pub key: K,
    pub value: V,
}

Fields§

§key: K§value: V

Implementations§

Source§

impl<K, V> PriorityEntry<K, V>

Source

pub fn new(key: K, value: V) -> Self

Examples found in repository?
examples/perf_features.rs (line 482)
475fn priority_sources(n: usize) -> Vec<PrioritySource<std::vec::IntoIter<PriorityEntry<u64, u64>>>> {
476    let per = n / STREAMS;
477    (0..STREAMS)
478        .map(|s| {
479            let stream = (0..per)
480                .map(move |i| {
481                    let key = ((s + i * STREAMS) as u64) / 2;
482                    PriorityEntry::new(key, key)
483                })
484                .collect::<Vec<_>>()
485                .into_iter();
486            PrioritySource::new((STREAMS - s) as i32, stream)
487        })
488        .collect()
489}
More examples
Hide additional examples
examples/sample_app.rs (line 216)
209fn memtable_wins_the_read() {
210    use subms_merge_iterator::{PriorityEntry, PriorityMergeIterator, PrioritySource};
211    println!("\n== priority: the memtable is authoritative ==");
212    let memtable = PrioritySource::new(
213        100,
214        PRICE_MEMTABLE
215            .iter()
216            .map(|&(k, v)| PriorityEntry::new(k, v))
217            .collect::<Vec<_>>()
218            .into_iter(),
219    );
220    let flushed = PrioritySource::new(
221        10,
222        PRICE_FLUSHED
223            .iter()
224            .map(|&(k, v)| PriorityEntry::new(k, v))
225            .collect::<Vec<_>>()
226            .into_iter(),
227    );
228
229    let view: Vec<(&str, i64)> = PriorityMergeIterator::new([memtable, flushed])
230        .map(|e| (e.key, e.value))
231        .collect();
232    println!("  resolved read view: {view:?}");
233    assert_eq!(
234        view,
235        vec![("AAPL", 152), ("MSFT", 300)],
236        "the memtable wins AAPL despite being registered first"
237    );
238}

Trait Implementations§

Source§

impl<K: Clone, V: Clone> Clone for PriorityEntry<K, V>

Source§

fn clone(&self) -> PriorityEntry<K, V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug, V: Debug> Debug for PriorityEntry<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Eq, V: Eq> Eq for PriorityEntry<K, V>

Source§

impl<K: PartialEq, V: PartialEq> PartialEq for PriorityEntry<K, V>

Source§

fn eq(&self, other: &PriorityEntry<K, V>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<K: PartialEq, V: PartialEq> StructuralPartialEq for PriorityEntry<K, V>

Auto Trait Implementations§

§

impl<K, V> Freeze for PriorityEntry<K, V>
where K: Freeze, V: Freeze,

§

impl<K, V> RefUnwindSafe for PriorityEntry<K, V>

§

impl<K, V> Send for PriorityEntry<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for PriorityEntry<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for PriorityEntry<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnsafeUnpin for PriorityEntry<K, V>
where K: UnsafeUnpin, V: UnsafeUnpin,

§

impl<K, V> UnwindSafe for PriorityEntry<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.