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

Function SortStructArray

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

Source from the content-addressed store, hash-verified

1162}
1163
1164Result<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
1193void RegisterVectorSort(FunctionRegistry* registry) {
1194 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