Struct dataflow_types::plan::Permutation [−][src]
pub struct Permutation { /* fields omitted */ }
Expand description
A permutation is applied to a Row
split into a key and a value part, and presents it as if
it is the row containing as its columns the columns referenced by permutation
. The key_arity
describes how many columns are in the key, which is important when joining relations and forming
joint permutations.
Arrangements conceptually store data split in key-value pairs, where all data is grouped by the key. It is desirable to remove redundancy between the key and value by not repeating columns in the value that are already present in the key. This struct provides an abstraction to encode this deduplication of columns in the key.
A Permutation consists of two parts: An expression to thin the columns in the value and a permutation defined on the key appended with the value to reconstruct the original value.
Example of an identity permutation
For identity mappings, the thinning leaves the value as-is and the permutation restores the original order of elements
- Input: key expressions of length
n
:[key_0, ..., key_n]
;arity
of the row - Thinning:
[0, ..., arity]
- Permutation:
[n, ..., n + arity]
Example of a non-identity permutation
We remove all columns from a row that are present in the key.
- Input: key expressions of length
n
:[key_0, ..., key_n]
;arity
of the row - Thinning:
[i \in 0, ..., arity | key_i != column reference]
- Permutation: for each column
i
in the input:- if
i
is in the key: offset ofColumn(i)
in key - offset in thinned row
- if
Joining permutations
For joined relations with thinned values, we need to construct a joined permutation to undo
the thinning. Let’s assume a join produces rows of the form [key, value_1, value_2]
where
the inputs where of the form [key, value_1]
and [key, value_2]
and the join groups on the
key.
Conceptually, the joined permutation is the permutation of the left relation appended with the permutation of the right permutation. The right permutation needs to be offset by the length of the thinned values of the left relation, while keeping key references unchanged.
- Input 1: Key Column(0), value Column(1), permutation
[0, 1]
- Input 2: Key Column(0), value Column(1), Column(2), permutation
[0, 1, 2]
- Joined relation:
- Key Column(0),
- Value Column(1) of input 1,
- Key Column(0),
- Column(1) of input 2,
- Column(2) of input 2.
- Result: Key Column(0), permutation
[0, 1, 0, 2, 3]
Implementations
Construct a permutation and thinning expression from a key description and the relation’s arity.
This constructs a permutation that removes redundant columns from the value if they are part of the key.
Construct an identity Permutation that expects all data in the value.
Compute the join of two permutations.
This assumes two relations [key, value_1]
and [key, value_2]
are joined into
[key, value_1, value_2]
and constructs a permutation accordingly.
Permute a [key, value]
row to reconstruct a non-permuted variant.
The function truncates the data to the length of the permutation, which should match the expectation of any subsequent map/filter/project or operator.
Example
let mut datum_vec = DatumVec::new();
let mut borrow = datum_vec.borrow_with_many(&[&key, &val]);
permutation.permute_in_place(&mut borrow);
Prepares the MFP mfp
to act on permuted input, according
to this permutation
Prepares the MfpPlan mfp
to act on permuted input, according
to this permutation
Prepares the SafeMfpPlan mfp
to act on permuted input, according
to this permutation
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Permutation
impl Send for Permutation
impl Sync for Permutation
impl Unpin for Permutation
impl UnwindSafe for Permutation
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more