-
Notifications
You must be signed in to change notification settings - Fork 2.2k
WIP Optimize hash_aggregate when there are no null group keys #922
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,6 +435,16 @@ macro_rules! eq_array_primitive { | |
| }}; | ||
| } | ||
|
|
||
| macro_rules! eq_array_no_nulls_primitive { | ||
| ($array:expr, $index:expr, $ARRAYTYPE:ident, $VALUE:expr) => {{ | ||
| let array = $array.as_any().downcast_ref::<$ARRAYTYPE>().unwrap(); | ||
| match $VALUE { | ||
| Some(val) => &array.value($index) == val, | ||
| None => false, | ||
| } | ||
| }}; | ||
| } | ||
|
|
||
| impl ScalarValue { | ||
| /// Getter for the `DataType` of the value | ||
| pub fn get_datatype(&self) -> DataType { | ||
|
|
@@ -1095,6 +1105,78 @@ impl ScalarValue { | |
| } | ||
| } | ||
|
|
||
|
|
||
| /// an unsafe version of `eq_array` optimised for the situation | ||
| /// where we know in advance that the array has no nulls | ||
| #[inline] | ||
| pub fn eq_array_no_nulls(&self, array: &ArrayRef, index:usize) -> bool { | ||
| if let DataType::Dictionary(key_type, _) = array.data_type() { | ||
| return self.eq_array_dictionary(array, index, key_type); | ||
|
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 think this should perhaps also be |
||
| } | ||
|
|
||
| match self { | ||
| ScalarValue::Boolean(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, BooleanArray, val) | ||
| } | ||
| ScalarValue::Float32(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, Float32Array, val) | ||
| } | ||
| ScalarValue::Float64(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, Float64Array, val) | ||
| } | ||
| ScalarValue::Int8(val) => eq_array_no_nulls_primitive!(array, index, Int8Array, val), | ||
| ScalarValue::Int16(val) => eq_array_no_nulls_primitive!(array, index, Int16Array, val), | ||
| ScalarValue::Int32(val) => eq_array_no_nulls_primitive!(array, index, Int32Array, val), | ||
| ScalarValue::Int64(val) => eq_array_no_nulls_primitive!(array, index, Int64Array, val), | ||
| ScalarValue::UInt8(val) => eq_array_no_nulls_primitive!(array, index, UInt8Array, val), | ||
| ScalarValue::UInt16(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, UInt16Array, val) | ||
| } | ||
| ScalarValue::UInt32(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, UInt32Array, val) | ||
| } | ||
| ScalarValue::UInt64(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, UInt64Array, val) | ||
| } | ||
| ScalarValue::Utf8(val) => eq_array_no_nulls_primitive!(array, index, StringArray, val), | ||
| ScalarValue::LargeUtf8(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, LargeStringArray, val) | ||
| } | ||
| ScalarValue::Binary(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, BinaryArray, val) | ||
| } | ||
| ScalarValue::LargeBinary(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, LargeBinaryArray, val) | ||
| } | ||
| ScalarValue::List(_, _) => unimplemented!(), | ||
| ScalarValue::Date32(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, Date32Array, val) | ||
| } | ||
| ScalarValue::Date64(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, Date64Array, val) | ||
| } | ||
| ScalarValue::TimestampSecond(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, TimestampSecondArray, val) | ||
| } | ||
| ScalarValue::TimestampMillisecond(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, TimestampMillisecondArray, val) | ||
| } | ||
| ScalarValue::TimestampMicrosecond(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, TimestampMicrosecondArray, val) | ||
| } | ||
| ScalarValue::TimestampNanosecond(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, TimestampNanosecondArray, val) | ||
| } | ||
| ScalarValue::IntervalYearMonth(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, IntervalYearMonthArray, val) | ||
| } | ||
| ScalarValue::IntervalDayTime(val) => { | ||
| eq_array_no_nulls_primitive!(array, index, IntervalDayTimeArray, val) | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /// Compares a dictionary array with indexes of type `key_type` | ||
| /// with the array @ index for equality with self | ||
| fn eq_array_dictionary( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.