-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Optimize Nullstate / accumulators
#19625
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
Changes from all commits
2e70075
5f9deea
fb249d6
0777794
bdeda6a
5332b17
05414e8
9be3b44
2e39af2
b00e8d8
68a498d
da2d7de
2c61002
f646fe8
47c46e7
4692d8d
5e0562c
d96c80a
24e8f52
c23f4d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,8 @@ where | |
| opt_filter, | ||
| total_num_groups, | ||
| |group_index, new_value| { | ||
| let value = &mut self.values[group_index]; | ||
| // SAFETY: group_index is guaranteed to be in bounds | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend adding safety notes to the docs of GroupsAccumulator in https://github.com/apache/datafusion/blob/36ec9f1de0aeabca60b8f7ebe07d650b8ef03506/datafusion/expr-common/src/groups_accumulator.rs#L114-L113 That explains that all group indexes are guaranteed to be <= |
||
| let value = unsafe { self.values.get_unchecked_mut(group_index) }; | ||
| (self.prim_fn)(value, new_value); | ||
| }, | ||
| ); | ||
|
|
@@ -117,7 +118,7 @@ where | |
| fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef> { | ||
| let values = emit_to.take_needed(&mut self.values); | ||
| let nulls = self.null_state.build(emit_to); | ||
| let values = PrimitiveArray::<T>::new(values.into(), Some(nulls)) // no copy | ||
| let values = PrimitiveArray::<T>::new(values.into(), nulls) // no copy | ||
| .with_data_type(self.data_type.clone()); | ||
| Ok(Arc::new(values)) | ||
| } | ||
|
|
||
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 possibility is to make this another another function to reduce some duplication and have a place it could be explained
Maybe something like
?
Though maybe an extra level of indirection would make it harder to follow.