PruningJoinHashMap

Struct PruningJoinHashMap 

Source
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

Source

pub(crate) fn with_capacity(capacity: usize) -> Self

Constructs a new PruningJoinHashMap with the given capacity. Both the map and the list are pre-allocated with the provided capacity.

§Arguments
  • capacity: The initial capacity of the hash map.
§Returns

A new instance of PruningJoinHashMap.

Source

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_factor when 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.

Source

pub(crate) fn size(&self) -> usize

Calculates the size of the PruningJoinHashMap in bytes.

§Returns

The size of the hash map in bytes.

Source

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.

Source§

fn extend_zero(&mut self, len: usize)

Source§

fn update_from_iter<'a>( &mut self, iter: Box<dyn Iterator<Item = (usize, &'a u64)> + Send + 'a>, deleted_offset: usize, )

Source§

fn get_matched_indices<'a>( &self, iter: Box<dyn Iterator<Item = (usize, &'a u64)> + 'a>, deleted_offset: Option<usize>, ) -> (Vec<u32>, Vec<u64>)

Source§

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>)>)

Source§

fn is_empty(&self) -> bool

Returns true if the join hash map contains no entries.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> ErasedDestructor for T
where T: 'static,