| 1113 | } |
| 1114 | |
| 1115 | Result<NullLikePartition> SortStructArray(ExecContext* ctx, std::span<uint64_t> indices, |
| 1116 | const StructArray& array, SortOrder sort_order, |
| 1117 | NullPlacement null_placement) { |
| 1118 | ARROW_ASSIGN_OR_RAISE(auto columns, array.Flatten()); |
| 1119 | auto batch = RecordBatch::Make(schema(array.type()->fields()), array.length(), |
| 1120 | std::move(columns)); |
| 1121 | |
| 1122 | auto options = SortOptions::Defaults(); |
| 1123 | options.sort_keys.reserve(array.num_fields()); |
| 1124 | for (int i = 0; i < array.num_fields(); ++i) { |
| 1125 | options.sort_keys.push_back(SortKey(FieldRef(i), sort_order, null_placement)); |
| 1126 | } |
| 1127 | |
| 1128 | ARROW_ASSIGN_OR_RAISE(auto sort_keys, |
| 1129 | ResolveRecordBatchSortKeys(*batch, options.GetSortKeys())); |
| 1130 | if (sort_keys.size() <= kMaxRadixSortKeys) { |
| 1131 | RadixRecordBatchSorter sorter(indices, std::move(sort_keys)); |
| 1132 | return sorter.Sort(); |
| 1133 | } else { |
| 1134 | MultipleKeyRecordBatchSorter sorter(indices, std::move(sort_keys)); |
| 1135 | return sorter.Sort(); |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | void RegisterVectorSort(FunctionRegistry* registry) { |
| 1140 | DCHECK_OK(registry->AddFunction(std::make_shared<SortIndicesMetaFunction>())); |
no test coverage detected