ArianaVillegas commented on code in PR #13334:
URL: https://github.com/apache/arrow/pull/13334#discussion_r913265623
##########
cpp/src/arrow/compute/kernels/vector_array_sort.cc:
##########
@@ -172,6 +173,85 @@ class ArrayCompareSorter {
}
};
+template <>
+class ArrayCompareSorter<DictionaryType> {
+ struct DictionaryInternal {
+ NullPartitionResult p;
+ const std::shared_ptr<Array>& values;
+ const std::shared_ptr<Array>& indices;
+ const UInt64Array& indices_values;
+ const ArraySortOptions& options;
+ int64_t offset;
+
+ Status Visit(const DataType& index_type) {
+ return Status::TypeError("Dictionary sorting not supported for index
type ",
+ index_type.ToString());
+ }
+
+ template <typename IndexType>
+ enable_if_t<is_integer_type<IndexType>::value, Status> Visit(
+ const IndexType& index_type) {
+ return SortInternal<IndexType>();
+ }
+
+ template <typename IndexType>
+ Status SortInternal() {
+ using ArrayType = typename TypeTraits<IndexType>::ArrayType;
+ using GetView = GetViewType<IndexType>;
+ const auto& indices_array = checked_cast<const ArrayType&>(*indices);
+
+ std::vector<uint64_t> sort_order(indices_values.length());
+ uint64_t cur = 0;
+ auto cur_idx =
GetViewType<UInt64Type>::LogicalValue(indices_values.GetView(cur));
+ auto cur_val = values->GetScalar(cur_idx);
+ for (int i = 0; i < indices_values.length(); i++) {
Review Comment:
This loop is assigning the same label to the same values. And I think I can
use rank instead of that loop, I'll go for that change.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]