pub struct DependencyMap {
map: IndexMap<PhysicalSortExpr, DependencyNode>,
}Expand description
Maps an expression –> DependencyNode
§Debugging / deplaying DependencyMap
This structure implements Display to assist debugging. For example:
DependencyMap: {
a@0 ASC --> (target: a@0 ASC, dependencies: [[]])
b@1 ASC --> (target: b@1 ASC, dependencies: [[a@0 ASC, c@2 ASC]])
c@2 ASC --> (target: c@2 ASC, dependencies: [[b@1 ASC, a@0 ASC]])
d@3 ASC --> (target: d@3 ASC, dependencies: [[c@2 ASC, b@1 ASC]])
}§Note on IndexMap Rationale
Using IndexMap (which preserves insert order) to ensure consistent results
across different executions for the same query. We could have used HashSet
and HashMap instead without any loss of functionality.
As an example, if existing orderings are
[a ASC, b ASC][c ASC]
Then both the following output orderings are valid
[a ASC, b ASC, c ASC][c ASC, a ASC, b ASC]
These are both valid as they are concatenated versions of the alternative
orderings. Had we used HashSet/HashMap, we couldn’t guarantee to generate
the same result among the possible two results in the example above.
Fields§
§map: IndexMap<PhysicalSortExpr, DependencyNode>Implementations§
Source§impl DependencyMap
impl DependencyMap
Sourcepub fn insert(
&mut self,
sort_expr: PhysicalSortExpr,
target_sort_expr: Option<PhysicalSortExpr>,
dependency: Option<PhysicalSortExpr>,
)
pub fn insert( &mut self, sort_expr: PhysicalSortExpr, target_sort_expr: Option<PhysicalSortExpr>, dependency: Option<PhysicalSortExpr>, )
Insert a new dependency of sort_expr (i.e. dependency) into the map
along with its target sort expression.
Methods from Deref<Target = IndexMap<PhysicalSortExpr, DependencyNode>>§
pub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Return the number of elements the map can hold without reallocating.
This number is a lower bound; the map might be able to hold more, but is guaranteed to be able to hold at least this many.
Computes in O(1) time.
pub fn iter(&self) -> Iter<'_, K, V>
pub fn iter(&self) -> Iter<'_, K, V>
Return an iterator over the key-value pairs of the map, in their order
pub fn keys(&self) -> Keys<'_, K, V>
pub fn keys(&self) -> Keys<'_, K, V>
Return an iterator over the keys of the map, in their order
pub fn values(&self) -> Values<'_, K, V>
pub fn values(&self) -> Values<'_, K, V>
Return an iterator over the values of the map, in their order
pub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Return true if an equivalent to key exists in the map.
Computes in O(1) time (average).
pub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get<Q>(&self, key: &Q) -> Option<&V>
Return a reference to the stored value for key, if it is present,
else None.
Computes in O(1) time (average).
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Return references to the stored key-value pair for the lookup key,
if it is present, else None.
Computes in O(1) time (average).
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
Return the index with references to the stored key-value pair for the
lookup key, if it is present, else None.
Computes in O(1) time (average).
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
Return the item index for key, if it is present, else None.
Computes in O(1) time (average).
pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
Search over a sorted map for a key.
Returns the position where that key is present, or the position where it can be inserted to
maintain the sort. See slice::binary_search for more details.
Computes in O(log(n)) time, which is notably less scalable than looking the key up
using [get_index_of][IndexMap::get_index_of], but this can also position missing keys.
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
Search over a sorted map with a comparator function.
Returns the position where that value is present, or the position where it can be inserted
to maintain the sort. See slice::binary_search_by for more details.
Computes in O(log(n)) time.
pub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F,
) -> Result<usize, usize>
pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
Search over a sorted map with an extraction function.
Returns the position where that value is present, or the position where it can be inserted
to maintain the sort. See slice::binary_search_by_key for more details.
Computes in O(log(n)) time.
pub fn is_sorted(&self) -> boolwhere
K: PartialOrd,
pub fn is_sorted(&self) -> boolwhere
K: PartialOrd,
Checks if the keys of this map are sorted.
pub fn is_sorted_by<'a, F>(&'a self, cmp: F) -> bool
pub fn is_sorted_by<'a, F>(&'a self, cmp: F) -> bool
Checks if this map is sorted using the given comparator function.
pub fn is_sorted_by_key<'a, F, T>(&'a self, sort_key: F) -> bool
pub fn is_sorted_by_key<'a, F, T>(&'a self, sort_key: F) -> bool
Checks if this map is sorted using the given sort-key function.
pub fn partition_point<P>(&self, pred: P) -> usize
pub fn partition_point<P>(&self, pred: P) -> usize
Returns the index of the partition point of a sorted map according to the given predicate (the index of the first element of the second partition).
See slice::partition_point for more details.
Computes in O(log(n)) time.
pub fn as_slice(&self) -> &Slice<K, V>
pub fn as_slice(&self) -> &Slice<K, V>
Returns a slice of all the key-value pairs in the map.
Computes in O(1) time.
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
Get a key-value pair by index
Valid indices are 0 <= index < self.len().
Computes in O(1) time.
pub fn get_range<R>(&self, range: R) -> Option<&Slice<K, V>>where
R: RangeBounds<usize>,
pub fn get_range<R>(&self, range: R) -> Option<&Slice<K, V>>where
R: RangeBounds<usize>,
Returns a slice of key-value pairs in the given range of indices.
Valid indices are 0 <= index < self.len().
Computes in O(1) time.
Trait Implementations§
Source§impl Debug for DependencyMap
impl Debug for DependencyMap
Source§impl Default for DependencyMap
impl Default for DependencyMap
Source§fn default() -> DependencyMap
fn default() -> DependencyMap
Source§impl Deref for DependencyMap
impl Deref for DependencyMap
Source§type Target = IndexMap<PhysicalSortExpr, DependencyNode>
type Target = IndexMap<PhysicalSortExpr, DependencyNode>
Auto Trait Implementations§
impl Freeze for DependencyMap
impl !RefUnwindSafe for DependencyMap
impl Send for DependencyMap
impl Sync for DependencyMap
impl Unpin for DependencyMap
impl !UnwindSafe for DependencyMap
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§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.