pub struct PruningJoinHashMap {
pub map: HashTable<(u64, u64)>,
pub next: VecDeque<u64>,
}Expand description
The PruningJoinHashMap is similar to a regular JoinHashMap, but with
the capability of pruning elements in an efficient manner. This structure
is particularly useful for cases where it’s necessary to remove elements
from the map based on their buffer order.
§Example
Let's continue the example of `JoinHashMap` and then show how `PruningJoinHashMap` would
handle the pruning scenario.
Insert the pair (10,4) into the `PruningJoinHashMap`:
map:
----------
| 10 | 5 |
| 20 | 3 |
----------
list:
---------------------
| 0 | 0 | 0 | 2 | 4 | <--- hash value 10 maps to 5,4,2 (which means indices values 4,3,1)
---------------------
Now, let's prune 3 rows from `PruningJoinHashMap`:
map:
---------
| 1 | 5 |
---------
list:
---------
| 2 | 4 | <--- hash value 10 maps to 2 (5 - 3), 1 (4 - 3), NA (2 - 3) (which means indices values 1,0)
---------
After pruning, the | 2 | 3 | entry is deleted from `PruningJoinHashMap` since
there are no values left for this key.Fields§
§map: HashTable<(u64, u64)>Stores hash value to last row index
next: VecDeque<u64>Stores indices in chained list data structure
Implementations§
Source§impl PruningJoinHashMap
impl PruningJoinHashMap
Sourcepub(crate) fn with_capacity(capacity: usize) -> Self
pub(crate) fn with_capacity(capacity: usize) -> Self
Sourcepub(crate) fn shrink_if_necessary(&mut self, scale_factor: usize)
pub(crate) fn shrink_if_necessary(&mut self, scale_factor: usize)
Shrinks the capacity of the hash map, if necessary, based on the provided scale factor.
§Arguments
scale_factor: The scale factor that determines how conservative the shrinking strategy is. The capacity will be reduced by 1/scale_factorwhen necessary.
§Note
Increasing the scale factor results in less aggressive capacity shrinking, leading to potentially higher memory usage but fewer resizes. Conversely, decreasing the scale factor results in more aggressive capacity shrinking, potentially leading to lower memory usage but more frequent resizing.
Sourcepub(crate) fn prune_hash_values(
&mut self,
prune_length: usize,
deleting_offset: u64,
shrink_factor: usize,
)
pub(crate) fn prune_hash_values( &mut self, prune_length: usize, deleting_offset: u64, shrink_factor: usize, )
Removes hash values from the map and the list based on the given pruning length and deleting offset.
§Arguments
prune_length: The number of elements to remove from the list.deleting_offset: The offset used to determine which hash values to remove from the map.
§Returns
A Result indicating whether the operation was successful.
Trait Implementations§
Source§impl JoinHashMapType for PruningJoinHashMap
Implementation of JoinHashMapType for PruningJoinHashMap.
impl JoinHashMapType for PruningJoinHashMap
Implementation of JoinHashMapType for PruningJoinHashMap.
fn extend_zero(&mut self, len: usize)
fn update_from_iter<'a>( &mut self, iter: Box<dyn Iterator<Item = (usize, &'a u64)> + Send + 'a>, deleted_offset: usize, )
fn get_matched_indices<'a>( &self, iter: Box<dyn Iterator<Item = (usize, &'a u64)> + 'a>, deleted_offset: Option<usize>, ) -> (Vec<u32>, Vec<u64>)
fn get_matched_indices_with_limit_offset( &self, hash_values: &[u64], limit: usize, offset: (usize, Option<u64>), ) -> (Vec<u32>, Vec<u64>, Option<(usize, Option<u64>)>)
Auto Trait Implementations§
impl Freeze for PruningJoinHashMap
impl RefUnwindSafe for PruningJoinHashMap
impl Send for PruningJoinHashMap
impl Sync for PruningJoinHashMap
impl Unpin for PruningJoinHashMap
impl UnwindSafe for PruningJoinHashMap
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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