pub struct ProjectionMask { /* private fields */ }Expand description
A ProjectionMask identifies a set of columns within a potentially nested schema to project
In particular, a ProjectionMask can be constructed from a list of leaf column indices
or root column indices where:
- Root columns are the direct children of the root schema, enumerated in order
- Leaf columns are the child-less leaves of the schema as enumerated by a depth-first search
For example, the schema
message schema {
REQUIRED boolean leaf_1;
REQUIRED GROUP group {
OPTIONAL int32 leaf_2;
OPTIONAL int64 leaf_3;
}
}Has roots ["leaf_1", "group"] and leaves ["leaf_1", "leaf_2", "leaf_3"]
For non-nested schemas, i.e. those containing only primitive columns, the root and leaves are the same
Implementations§
Source§impl ProjectionMask
impl ProjectionMask
Sourcepub fn all() -> Self
pub fn all() -> Self
Create a ProjectionMask which selects all columns
Sourcepub fn none(len: usize) -> Self
pub fn none(len: usize) -> Self
Create a ProjectionMask which selects no columns
Sourcepub fn leaves(
schema: &SchemaDescriptor,
indices: impl IntoIterator<Item = usize>,
) -> Self
pub fn leaves( schema: &SchemaDescriptor, indices: impl IntoIterator<Item = usize>, ) -> Self
Create a ProjectionMask which selects only the specified leaf columns
Note: repeated or out of order indices will not impact the final mask
i.e. [0, 1, 2] will construct the same mask as [1, 0, 0, 2]
Sourcepub fn roots(
schema: &SchemaDescriptor,
indices: impl IntoIterator<Item = usize>,
) -> Self
pub fn roots( schema: &SchemaDescriptor, indices: impl IntoIterator<Item = usize>, ) -> Self
Create a ProjectionMask which selects only the specified root columns
Note: repeated or out of order indices will not impact the final mask
i.e. [0, 1, 2] will construct the same mask as [1, 0, 0, 2]
Sourcepub fn columns<'a>(
schema: &SchemaDescriptor,
names: impl IntoIterator<Item = &'a str>,
) -> Self
pub fn columns<'a>( schema: &SchemaDescriptor, names: impl IntoIterator<Item = &'a str>, ) -> Self
Create a ProjectionMask which selects only the named columns
All leaf columns that fall below a given name will be selected. For example, given the schema
message schema {
OPTIONAL group a (MAP) {
REPEATED group key_value {
REQUIRED BYTE_ARRAY key (UTF8); // leaf index 0
OPTIONAL group value (MAP) {
REPEATED group key_value {
REQUIRED INT32 key; // leaf index 1
REQUIRED BOOLEAN value; // leaf index 2
}
}
}
}
REQUIRED INT32 b; // leaf index 3
REQUIRED DOUBLE c; // leaf index 4
}["a.key_value.value", "c"] would return leaf columns 1, 2, and 4. ["a"] would return
columns 0, 1, and 2.
Note: repeated or out of order indices will not impact the final mask.
i.e. ["b", "c"] will construct the same mask as ["c", "b", "c"].
Also, this will not produce the desired results if a column contains a ‘.’ in its name.
Use Self::leaves or Self::roots in that case.
Sourcepub fn leaf_included(&self, leaf_idx: usize) -> bool
pub fn leaf_included(&self, leaf_idx: usize) -> bool
Returns true if the leaf column leaf_idx is included by the mask
Trait Implementations§
Source§impl Clone for ProjectionMask
impl Clone for ProjectionMask
Source§fn clone(&self) -> ProjectionMask
fn clone(&self) -> ProjectionMask
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more