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

Method applyMap

bolt/expression/CastExpr.cpp:80–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 }()
79
80VectorPtr CastExpr::applyMap(
81 const SelectivityVector& rows,
82 const MapVector* input,
83 exec::EvalCtx& context,
84 const MapType& fromType,
85 const MapType& toType) {
86 // Cast input keys/values vector to output keys/values vector using their
87 // element selectivity vector
88
89 // Initialize nested rows
90 auto mapKeys = input->mapKeys();
91 auto mapValues = input->mapValues();
92
93 SelectivityVector nestedRows;
94 BufferPtr elementToTopLevelRows;
95 if (fromType.keyType() != toType.keyType() ||
96 fromType.valueType() != toType.valueType()) {
97 nestedRows = functions::toElementRows(mapKeys->size(), rows, input);
98 elementToTopLevelRows = functions::getElementToTopLevelRows(
99 mapKeys->size(), rows, input, context.pool());
100 }
101
102 ErrorVectorPtr oldErrors;
103 context.swapErrors(oldErrors);
104
105 // Cast keys
106 VectorPtr newMapKeys;
107 if (fromType.keyType() == toType.keyType()) {
108 newMapKeys = input->mapKeys();
109 } else {
110 {
111 ScopedVarSetter holder(&inTopLevel, false);
112 apply(
113 nestedRows,
114 mapKeys,
115 context,
116 fromType.keyType(),
117 toType.keyType(),
118 newMapKeys);
119 }
120 }
121
122 // Cast values
123 VectorPtr newMapValues;
124 if (fromType.valueType() == toType.valueType()) {
125 newMapValues = mapValues;
126 } else {
127 {
128 ScopedVarSetter holder(&inTopLevel, false);
129 apply(
130 nestedRows,
131 mapValues,
132 context,
133 fromType.valueType(),
134 toType.valueType(),
135 newMapValues);
136 }
137 }

Callers

nothing calls this directly

Calls 15

toElementRowsFunction · 0.85
applyFunction · 0.85
MAPFunction · 0.85
valueTypeMethod · 0.80
swapErrorsMethod · 0.80
rawSizesMethod · 0.80
applyToSelectedMethod · 0.80
getElementToTopLevelRowsFunction · 0.50
mapKeysMethod · 0.45
mapValuesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected