pub struct GroupOrderingFull {
state: State,
}Expand description
Tracks grouping state when the data is ordered entirely by its group keys
When the group values are sorted, as soon as we see group n+1 we
know we will never see any rows for group n again and thus they
can be emitted.
For example, given SUM(amt) GROUP BY id if the input is sorted
by id as soon as a new id value is seen all previous values
can be emitted.
The state is tracked like this:
┌─────┐ ┌──────────────────┐
│┌───┐│ │ ┌──────────────┐ │ ┏━━━━━━━━━━━━━━┓
││ 0 ││ │ │ 123 │ │ ┌─────┃ 13 ┃
│└───┘│ │ └──────────────┘ │ │ ┗━━━━━━━━━━━━━━┛
│ ... │ │ ... │ │
│┌───┐│ │ ┌──────────────┐ │ │ current
││12 ││ │ │ 234 │ │ │
│├───┤│ │ ├──────────────┤ │ │
││12 ││ │ │ 234 │ │ │
│├───┤│ │ ├──────────────┤ │ │
││13 ││ │ │ 456 │◀┼───┘
│└───┘│ │ └──────────────┘ │
└─────┘ └──────────────────┘
group indices group_values current tracks the most
(in group value recent group index
order)In this diagram, the current group is 13, and thus groups
0..12 can be emitted. Note that 13 can not yet be emitted as
there may be more values in the next batch with the same group_id.
Fields§
§state: StateImplementations§
Source§impl GroupOrderingFull
impl GroupOrderingFull
pub fn new() -> GroupOrderingFull
pub fn emit_to(&self) -> Option<EmitTo>
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, total_num_groups: usize)
pub fn new_groups(&mut self, total_num_groups: usize)
Called when new groups are added in a batch. See documentation
on super::GroupOrdering::new_groups
Trait Implementations§
Source§impl Debug for GroupOrderingFull
impl Debug for GroupOrderingFull
Source§impl Default for GroupOrderingFull
impl Default for GroupOrderingFull
Source§fn default() -> GroupOrderingFull
fn default() -> GroupOrderingFull
Auto Trait Implementations§
impl Freeze for GroupOrderingFull
impl RefUnwindSafe for GroupOrderingFull
impl Send for GroupOrderingFull
impl Sync for GroupOrderingFull
impl Unpin for GroupOrderingFull
impl UnwindSafe for GroupOrderingFull
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