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