MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / make_count

Function make_count

extensions/expression-language/Expression.cpp:1343–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1341}
1342
1343Expression make_count(const std::string &function_name, const std::vector<Expression> &args) {
1344 if (args.size() != 1) {
1345 std::stringstream message_ss;
1346 message_ss << "Expression language function " << function_name << " called with " << args.size() << " argument(s), but " << 1 << " are required";
1347 throw std::runtime_error(message_ss.str());
1348 }
1349
1350 if (!args[0].is_multi()) {
1351 std::stringstream message_ss;
1352 message_ss << "Expression language function " << function_name << " called against singular expression.";
1353 throw std::runtime_error(message_ss.str());
1354 }
1355
1356 return args[0].make_aggregate([](const Parameters &params,
1357 const std::vector<Expression> &sub_exprs) -> Value {
1358 uint64_t count = 0;
1359 for (const auto &sub_expr : sub_exprs) {
1360 if (sub_expr(params).asBoolean()) {
1361 count++;
1362 }
1363 }
1364 return Value(count);
1365 });
1366}
1367
1368Expression make_join(const std::string &function_name, const std::vector<Expression> &args) {
1369 if (args.size() != 2) {

Callers 1

make_dynamic_functionFunction · 0.85

Calls 5

is_multiMethod · 0.80
make_aggregateMethod · 0.80
asBooleanMethod · 0.80
ValueClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected