You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/11 00:53:17 UTC
[GitHub] [arrow-rs] viirya opened a new pull request, #2701: Add support of sorting dictionary of other primitive arrays
viirya opened a new pull request, #2701:
URL: https://github.com/apache/arrow-rs/pull/2701
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Closes #2700.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!---
If there are any breaking changes to public APIs, please add the `breaking change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971071599
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,107 +314,183 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
DataType::Int8 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int16 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int32 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int64 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt8 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt16 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt32 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt64 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
+ let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
+ let value_indices_map = prepare_indices_map(&sorted_value_indices);
+ sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
+ },
+ DataType::Float32 => {
Review Comment:
Yea, forgot that this matches value types. 😅
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] ursabot commented on pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#issuecomment-1247308125
Benchmark runs are scheduled for baseline = 51466634f11b7d965ca3c912835c91e0f84a6c92 and contender = 2a0fc7703420f99d28141516cabdd0408a583dfc. 2a0fc7703420f99d28141516cabdd0408a583dfc is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/b05c58b424d7441692df171c940d9df7...ef4691b8a8d74fd7887f0f6c38329856/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/295fd03326eb49d7bb3f7fb918b2ef6e...8f27f18629de4d7e8c8fc10346dcd434/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/36ff4dd6bcf7405a8b1db3178fcda297...3af3cf0574934b3f89980123c472de4f/)
[Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/ec057b5b2c1046589d2efd7f3e88b227...4c7ff86a1b8a410ca6a535bfb38c34fd/)
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971128818
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,119 +314,40 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
- DataType::Int8 => {
- let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
- let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
- let value_indices_map = prepare_indices_map(&sorted_value_indices);
- sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
- },
- DataType::Int16 => {
+ DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 | DataType::UInt8 |
+ DataType::UInt16 | DataType::UInt32 | DataType::UInt64 | DataType::Float32 | DataType::Float64 |
+ DataType::Date32 | DataType::Date64 | DataType::Time32(Second) | DataType::Time32(Millisecond) |
+ DataType::Time64(Microsecond) | DataType::Time64(Nanosecond) | DataType::Timestamp(Second, _) |
Review Comment:
Do we need to match the specific TimeUnits/IntervalUnits?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya merged pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
viirya merged PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971128818
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,119 +314,40 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
- DataType::Int8 => {
- let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
- let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
- let value_indices_map = prepare_indices_map(&sorted_value_indices);
- sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
- },
- DataType::Int16 => {
+ DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 | DataType::UInt8 |
+ DataType::UInt16 | DataType::UInt32 | DataType::UInt64 | DataType::Float32 | DataType::Float64 |
+ DataType::Date32 | DataType::Date64 | DataType::Time32(Second) | DataType::Time32(Millisecond) |
+ DataType::Time64(Microsecond) | DataType::Time64(Nanosecond) | DataType::Timestamp(Second, _) |
Review Comment:
Do we need to match the specific TimeUnits?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971262523
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,119 +314,40 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
- DataType::Int8 => {
- let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
- let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
- let value_indices_map = prepare_indices_map(&sorted_value_indices);
- sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
- },
- DataType::Int16 => {
+ DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 | DataType::UInt8 |
+ DataType::UInt16 | DataType::UInt32 | DataType::UInt64 | DataType::Float32 | DataType::Float64 |
+ DataType::Date32 | DataType::Date64 | DataType::Time32(Second) | DataType::Time32(Millisecond) |
+ DataType::Time64(Microsecond) | DataType::Time64(Nanosecond) | DataType::Timestamp(Second, _) |
Review Comment:
No, I think. Just copied from above match statements. Removed them now.
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,119 +314,40 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
- DataType::Int8 => {
- let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
- let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
- let value_indices_map = prepare_indices_map(&sorted_value_indices);
- sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
- },
- DataType::Int16 => {
+ DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 | DataType::UInt8 |
Review Comment:
Added one helper function for that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971003440
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,107 +314,183 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
DataType::Int8 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int16 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int32 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
},
DataType::Int64 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt8 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt16 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt32 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
let value_indices_map = prepare_indices_map(&sorted_value_indices);
sort_primitive_dictionary::<_, _>(values, &value_indices_map,v, n, options, limit, cmp)
},
DataType::UInt64 => {
let dict_values = values.values();
- let value_null_first = if options.descending {
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
+ let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
+ let value_indices_map = prepare_indices_map(&sorted_value_indices);
+ sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
+ },
+ DataType::Float32 => {
Review Comment:
Perhaps we could collapse these match statements together, they appear to all be identical?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] tustvold commented on a diff in pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#discussion_r971127149
##########
arrow/src/compute/kernels/sort.rs:
##########
@@ -314,119 +314,40 @@ pub fn sort_to_indices(
}
},
DataType::Dictionary(_, _) => {
+ let value_null_first = if options.descending {
+ // When sorting dictionary in descending order, we take inverse of of null ordering
+ // when sorting the values. Because if `nulls_first` is true, null must be in front
+ // of non-null value. As we take the sorted order of value array to sort dictionary
+ // keys, these null values will be treated as smallest ones and be sorted to the end
+ // of sorted result. So we set `nulls_first` to false when sorting dictionary value
+ // array to make them as largest ones, then null values will be put at the beginning
+ // of sorted dictionary result.
+ !options.nulls_first
+ } else {
+ options.nulls_first
+ };
+ let value_options = Some(SortOptions {
+ descending: false,
+ nulls_first: value_null_first,
+ });
downcast_dictionary_array!(
values => match values.values().data_type() {
- DataType::Int8 => {
- let dict_values = values.values();
- let value_null_first = if options.descending {
- // When sorting dictionary in descending order, we take inverse of of null ordering
- // when sorting the values. Because if `nulls_first` is true, null must be in front
- // of non-null value. As we take the sorted order of value array to sort dictionary
- // keys, these null values will be treated as smallest ones and be sorted to the end
- // of sorted result. So we set `nulls_first` to false when sorting dictionary value
- // array to make them as largest ones, then null values will be put at the beginning
- // of sorted dictionary result.
- !options.nulls_first
- } else {
- options.nulls_first
- };
- let value_options = Some(SortOptions { descending: false, nulls_first: value_null_first });
- let sorted_value_indices = sort_to_indices(dict_values, value_options, None)?;
- let value_indices_map = prepare_indices_map(&sorted_value_indices);
- sort_primitive_dictionary::<_, _>(values, &value_indices_map, v, n, options, limit, cmp)
- },
- DataType::Int16 => {
+ DataType::Int8 | DataType::Int16 | DataType::Int32 | DataType::Int64 | DataType::UInt8 |
Review Comment:
I wonder if this should be a member function somewhere...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-rs] viirya commented on pull request #2701: Add support of sorting dictionary of other primitive arrays
Posted by GitBox <gi...@apache.org>.
viirya commented on PR #2701:
URL: https://github.com/apache/arrow-rs/pull/2701#issuecomment-1247302243
Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org