pub struct PriorityEntry<K, V> {
pub key: K,
pub value: V,
}Fields§
§key: K§value: VImplementations§
Source§impl<K, V> PriorityEntry<K, V>
impl<K, V> PriorityEntry<K, V>
Sourcepub fn new(key: K, value: V) -> Self
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
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>
impl<K: Clone, V: Clone> Clone for PriorityEntry<K, V>
Source§fn clone(&self) -> PriorityEntry<K, V>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<K: Eq, V: Eq> Eq for PriorityEntry<K, V>
impl<K: PartialEq, V: PartialEq> StructuralPartialEq for PriorityEntry<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for PriorityEntry<K, V>
impl<K, V> RefUnwindSafe for PriorityEntry<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for PriorityEntry<K, V>
impl<K, V> Sync for PriorityEntry<K, V>
impl<K, V> Unpin for PriorityEntry<K, V>
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> 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