| 1162 | } |
| 1163 | |
| 1164 | Result<NullPartitionResult> SortStructArray(ExecContext* ctx, uint64_t* indices_begin, |
| 1165 | uint64_t* indices_end, |
| 1166 | const StructArray& array, |
| 1167 | SortOrder sort_order, |
| 1168 | NullPlacement null_placement) { |
| 1169 | ARROW_ASSIGN_OR_RAISE(auto columns, array.Flatten()); |
| 1170 | auto batch = RecordBatch::Make(schema(array.type()->fields()), array.length(), |
| 1171 | std::move(columns)); |
| 1172 | |
| 1173 | auto options = SortOptions::Defaults(); |
| 1174 | options.null_placement = null_placement; |
| 1175 | options.sort_keys.reserve(array.num_fields()); |
| 1176 | for (int i = 0; i < array.num_fields(); ++i) { |
| 1177 | options.sort_keys.push_back(SortKey(FieldRef(i), sort_order)); |
| 1178 | } |
| 1179 | |
| 1180 | ARROW_ASSIGN_OR_RAISE(auto sort_keys, |
| 1181 | ResolveRecordBatchSortKeys(*batch, options.sort_keys)); |
| 1182 | if (sort_keys.size() <= kMaxRadixSortKeys) { |
| 1183 | RadixRecordBatchSorter sorter(indices_begin, indices_end, std::move(sort_keys), |
| 1184 | options); |
| 1185 | return sorter.Sort(); |
| 1186 | } else { |
| 1187 | MultipleKeyRecordBatchSorter sorter(indices_begin, indices_end, std::move(sort_keys), |
| 1188 | options); |
| 1189 | return sorter.Sort(); |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | void RegisterVectorSort(FunctionRegistry* registry) { |
| 1194 | DCHECK_OK(registry->AddFunction(std::make_shared<SortIndicesMetaFunction>())); |
no test coverage detected