MCPcopy Create free account
hub / github.com/bytedance/bolt / reorderInputChannels

Function reorderInputChannels

bolt/exec/WindowBuild.cpp:38–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37namespace {
38std::tuple<std::vector<column_index_t>, std::vector<column_index_t>, RowTypePtr>
39reorderInputChannels(
40 const RowTypePtr& inputType,
41 const std::vector<core::FieldAccessTypedExprPtr>& partitionKeys,
42 const std::vector<core::FieldAccessTypedExprPtr>& sortingKeys) {
43 const auto size = inputType->size();
44
45 std::vector<column_index_t> channels;
46 std::vector<column_index_t> inversedChannels;
47 std::vector<std::string> names;
48 std::vector<TypePtr> types;
49 channels.reserve(size);
50 inversedChannels.resize(size);
51 names.reserve(size);
52 types.reserve(size);
53
54 std::unordered_set<std::string> keyNames;
55
56 auto appendChannel =
57 [&inputType, &channels, &inversedChannels, &names, &types](
58 column_index_t channel) {
59 channels.push_back(channel);
60 inversedChannels[channel] = channels.size() - 1;
61 names.push_back(inputType->nameOf(channel));
62 types.push_back(inputType->childAt(channel));
63 };
64
65 for (const auto& key : partitionKeys) {
66 auto channel = exprToChannel(key.get(), inputType);
67 appendChannel(channel);
68 keyNames.insert(key->name());
69 }
70
71 for (const auto& key : sortingKeys) {
72 auto channel = exprToChannel(key.get(), inputType);
73 appendChannel(channel);
74 keyNames.insert(key->name());
75 }
76
77 for (auto i = 0; i < size; ++i) {
78 if (keyNames.count(inputType->nameOf(i)) == 0) {
79 appendChannel(i);
80 }
81 }
82
83 return std::make_tuple(
84 channels, inversedChannels, ROW(std::move(names), std::move(types)));
85}
86
87// Returns a [start, end) slice of the 'types' vector.
88std::vector<TypePtr>

Callers 1

WindowBuildMethod · 0.70

Calls 12

exprToChannelFunction · 0.85
ROWFunction · 0.85
childAtMethod · 0.80
sizeMethod · 0.45
reserveMethod · 0.45
resizeMethod · 0.45
push_backMethod · 0.45
nameOfMethod · 0.45
getMethod · 0.45
insertMethod · 0.45
nameMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected