Skip to content

Commit

Permalink
Merge branch 'apache:main' into apacheGH-36072
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingurney committed Jun 20, 2023
2 parents c9848a4 + f959a2e commit 4899fe7
Show file tree
Hide file tree
Showing 12 changed files with 412 additions and 84 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Expand Up @@ -21,6 +21,7 @@ Checks: |
-clang-analyzer-alpha*,
google-*,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
# produce HeaderFilterRegex from cpp/build-support/lint_exclusions.txt with:
Expand Down
23 changes: 22 additions & 1 deletion cpp/src/arrow/compute/kernels/vector_array_sort.cc
Expand Up @@ -262,6 +262,19 @@ class ArrayCompareSorter<DictionaryType> {
}
};

template <>
class ArrayCompareSorter<StructType> {
public:
Result<NullPartitionResult> operator()(uint64_t* indices_begin, uint64_t* indices_end,
const Array& array, int64_t offset,
const ArraySortOptions& options,
ExecContext* ctx) {
const auto& struct_array = checked_cast<const StructArray&>(array);
return SortStructArray(ctx, indices_begin, indices_end, struct_array, options.order,
options.null_placement);
}
};

template <typename ArrowType>
class ArrayCountSorter {
using ArrayType = typename TypeTraits<ArrowType>::ArrayType;
Expand Down Expand Up @@ -497,7 +510,7 @@ template <typename Type>
struct ArraySorter<
Type, enable_if_t<is_floating_type<Type>::value || is_base_binary_type<Type>::value ||
is_fixed_size_binary_type<Type>::value ||
is_dictionary_type<Type>::value>> {
is_dictionary_type<Type>::value || is_struct_type<Type>::value>> {
ArrayCompareSorter<Type> impl;
};

Expand Down Expand Up @@ -606,6 +619,13 @@ void AddDictArraySortingKernels(VectorKernel base, VectorFunction* func) {
DCHECK_OK(func->AddKernel(base));
}

template <template <typename...> class ExecTemplate>
void AddStructArraySortingKernels(VectorKernel base, VectorFunction* func) {
base.signature = KernelSignature::Make({Type::STRUCT}, uint64());
base.exec = ExecTemplate<UInt64Type, StructType>::Exec;
DCHECK_OK(func->AddKernel(base));
}

const ArraySortOptions* GetDefaultArraySortOptions() {
static const auto kDefaultArraySortOptions = ArraySortOptions::Defaults();
return &kDefaultArraySortOptions;
Expand Down Expand Up @@ -661,6 +681,7 @@ void RegisterVectorArraySort(FunctionRegistry* registry) {
base.exec_chunked = ArraySortIndicesChunked;
AddArraySortingKernels<ArraySortIndices>(base, array_sort_indices.get());
AddDictArraySortingKernels<ArraySortIndices>(base, array_sort_indices.get());
AddStructArraySortingKernels<ArraySortIndices>(base, array_sort_indices.get());
DCHECK_OK(registry->AddFunction(std::move(array_sort_indices)));

// partition_nth_indices has a parameter so needs its init function
Expand Down

0 comments on commit 4899fe7

Please sign in to comment.