MCPcopy Create free account
hub / github.com/apache/arrow / SortStructArray

Function SortStructArray

cpp/src/arrow/compute/kernels/vector_sort.cc:1170–1194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1168}
1169
1170Result<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
1196void RegisterVectorSort(FunctionRegistry* registry) {
1197 DCHECK_OK(registry->AddFunction(std::make_shared<SortIndicesMetaFunction>()));

Callers 1

operator()Method · 0.85

Calls 13

push_backMethod · 0.80
MakeFunction · 0.50
schemaFunction · 0.50
DefaultsFunction · 0.50
SortKeyClass · 0.50
FieldRefFunction · 0.50
fieldsMethod · 0.45
typeMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45
num_fieldsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected