-
Notifications
You must be signed in to change notification settings - Fork 0
Add specilized impl for array agg group accumulator #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: add-register_metadata
Are you sure you want to change the base?
Add specilized impl for array agg group accumulator #2
Conversation
if matches!(group_indices_order_mode, InputOrderMode::Sorted) { | ||
return Ok(Box::new(SortedArrayAggGroupAccumulator { | ||
inputs: vec![], | ||
lengths: vec![], | ||
current_group: None, | ||
item_data_type: self.data_type, | ||
})); | ||
} else { | ||
return Ok(self); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If self was mutable we would not be able to have special implementation for sorted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to to that would be potentially to use an enum:
enum ArrayAggGroupAccumulator {
Unsorted {
data_type: DataType,
adapter: GroupsAccumulatorAdapter,
},
Sorted {
inputs: Vec<ArrayRef>,
lengths: Vec<usize>,
// (group_index, length)
current_group: Option<(usize, usize)>,
item_data_type: DataType,
}
}
So this code would look lke
impl GroupsAccumulator for ArrayAggGroupAccumulator {
fn with_group_indices_order_mode(
&mut self,
group_indices_order_mode: &datafusion_expr_common::ordering::InputOrderMode,
) -> Result<()> {
if matches!(group_indices_order_mode, InputOrderMode::Sorted) {
*self = Self::Sorted {
inputs: vec![],
lengths: vec![],
current_group: None,
item_data_type: self.data_type,
};
}
Ok(())
}
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but this it has a cost rather for matching but I'm ok in using mutable as well
02e893b
to
c736bd8
Compare
No description provided.