pub struct GroupOrderingPartial {
state: State,
order_indices: Vec<usize>,
}Expand description
Tracks grouping state when the data is ordered by some subset of the group keys.
Once the next sort key value is seen, never see groups with that sort key again, so we can emit all groups with the previous sort key and earlier.
For example, given SUM(amt) GROUP BY id, state if the input is
sorted by state, when a new value of state is seen, all groups
with prior values of state can be emitted.
The state is tracked like this:
┏━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━┓
┌─────┐ ┌───────────────────┐ ┌─────┃ 9 ┃ ┃ "MD" ┃
│┌───┐│ │ ┌──────────────┐ │ │ ┗━━━━━━━━━━━━━━━━━┛ ┗━━━━━━━┛
││ 0 ││ │ │ 123, "MA" │ │ │ current_sort sort_key
│└───┘│ │ └──────────────┘ │ │
│ ... │ │ ... │ │ current_sort tracks the
│┌───┐│ │ ┌──────────────┐ │ │ smallest group index that had
││ 8 ││ │ │ 765, "MA" │ │ │ the same sort_key as current
│├───┤│ │ ├──────────────┤ │ │
││ 9 ││ │ │ 923, "MD" │◀─┼─┘
│├───┤│ │ ├──────────────┤ │ ┏━━━━━━━━━━━━━━┓
││10 ││ │ │ 345, "MD" │ │ ┌─────┃ 11 ┃
│├───┤│ │ ├──────────────┤ │ │ ┗━━━━━━━━━━━━━━┛
││11 ││ │ │ 124, "MD" │◀─┼──┘ current
│└───┘│ │ └──────────────┘ │
└─────┘ └───────────────────┘
group indices
(in group value group_values current tracks the most
order) recent group indexFields§
§state: State§order_indices: Vec<usize>Implementations§
Source§impl GroupOrderingPartial
impl GroupOrderingPartial
Sourcepub fn try_new(
order_indices: Vec<usize>,
) -> Result<GroupOrderingPartial, DataFusionError>
pub fn try_new( order_indices: Vec<usize>, ) -> Result<GroupOrderingPartial, DataFusionError>
TODO: Remove unnecessary input_schema parameter.
Sourcepub fn emit_to(&self) -> Option<EmitTo>
pub fn emit_to(&self) -> Option<EmitTo>
How many groups be emitted, or None if no data can be emitted
Sourcepub fn remove_groups(&mut self, n: usize)
pub fn remove_groups(&mut self, n: usize)
remove the first n groups from the internal state, shifting
all existing indexes down by n
Sourcepub fn input_done(&mut self)
pub fn input_done(&mut self)
Note that the input is complete so any outstanding groups are done as well
Sourcepub fn new_groups(
&mut self,
batch_group_values: &[Arc<dyn Array>],
group_indices: &[usize],
total_num_groups: usize,
) -> Result<(), DataFusionError>
pub fn new_groups( &mut self, batch_group_values: &[Arc<dyn Array>], group_indices: &[usize], total_num_groups: usize, ) -> Result<(), DataFusionError>
Called when new groups are added in a batch. See documentation
on super::GroupOrdering::new_groups
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GroupOrderingPartial
impl !RefUnwindSafe for GroupOrderingPartial
impl Send for GroupOrderingPartial
impl Sync for GroupOrderingPartial
impl Unpin for GroupOrderingPartial
impl !UnwindSafe for GroupOrderingPartial
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