From 62b9d016af1ff3014784b9efb373ce00061eb715 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Wed, 23 Jun 2021 15:30:44 -0400 Subject: [PATCH 01/16] adding bool sort and partition_nth_indices --- cpp/src/arrow/compute/kernels/vector_sort.cc | 23 ++++++++++++ .../arrow/compute/kernels/vector_sort_test.cc | 35 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc index 6c425d65550..e84b952f1be 100644 --- a/cpp/src/arrow/compute/kernels/vector_sort.cc +++ b/cpp/src/arrow/compute/kernels/vector_sort.cc @@ -370,6 +370,17 @@ inline void VisitRawValuesInline(const ArrayType& values, [&](int64_t i) { visitor_not_null(data[i]); }, [&]() { visitor_null(); }); } +template +inline void VisitRawValuesInline(const BooleanArray& values, + VisitorNotNull&& visitor_not_null, + VisitorNull&& visitor_null) { + const uint8_t* data = values.data()->buffers[1]->data(); + VisitBitBlocksVoid( + values.null_bitmap(), values.offset(), values.length(), + [&](int64_t i) { visitor_not_null(BitUtil::GetBit(data, values.offset() + i)); }, + [&]() { visitor_null(); }); +} + template class ArrayCompareSorter { using ArrayType = typename TypeTraits::ArrayType; @@ -527,6 +538,12 @@ class ArrayCountOrCompareSorter { template struct ArraySorter; +template <> +struct ArraySorter { + ArrayCountSorter impl; + ArraySorter() : impl(false, true) {} +}; + template <> struct ArraySorter { ArrayCountSorter impl; @@ -576,11 +593,17 @@ struct ArraySortIndices { // Sort indices kernels implemented for // +// * Boolean type // * Number types // * Base binary types template