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

Function SortStructArray

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

Source from the content-addressed store, hash-verified

1113}
1114
1115Result<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
1139void RegisterVectorSort(FunctionRegistry* registry) {
1140 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