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

Function ModifyExpression

cpp/src/arrow/compute/util.h:138–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136/// argument. If no arguments were modified the unmodified Expression* will be nullptr.
137template <typename PreVisit, typename PostVisitCall>
138Result<Expression> ModifyExpression(Expression expr, const PreVisit& pre,
139 const PostVisitCall& post_call) {
140 ARROW_ASSIGN_OR_RAISE(expr, Result<Expression>(pre(std::move(expr))));
141
142 auto call = expr.call();
143 if (!call) return expr;
144
145 bool at_least_one_modified = false;
146 std::vector<Expression> modified_arguments;
147
148 for (size_t i = 0; i < call->arguments.size(); ++i) {
149 ARROW_ASSIGN_OR_RAISE(auto modified_argument,
150 ModifyExpression(call->arguments[i], pre, post_call));
151
152 if (Expression::Identical(modified_argument, call->arguments[i])) {
153 continue;
154 }
155
156 if (!at_least_one_modified) {
157 modified_arguments = call->arguments;
158 at_least_one_modified = true;
159 }
160
161 modified_arguments[i] = std::move(modified_argument);
162 }
163
164 if (at_least_one_modified) {
165 // reconstruct the call expression with the modified arguments
166 auto modified_call = *call;
167 modified_call.arguments = std::move(modified_arguments);
168 return post_call(Expression(std::move(modified_call)), &expr);
169 }
170
171 return post_call(std::move(expr), NULLPTR);
172}
173
174// Helper class to calculate the modified number of rows to process using SIMD.
175//

Callers 6

DevolveFilterMethod · 0.85
FoldConstantsFunction · 0.85
CanonicalizeFunction · 0.85
SimplifyIsValidGuaranteeFunction · 0.85
RemoveNamedRefsFunction · 0.85

Calls 4

callMethod · 0.80
ExpressionClass · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected