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

Method processOnTrigger

extensions/sql/processors/ExecuteSQL.cpp:90–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void ExecuteSQL::processOnTrigger(core::ProcessSession& session) {
91 auto statement = connection_->prepareStatement(sqlSelectQuery_);
92
93 auto rowset = statement->execute();
94
95 int count = 0;
96 size_t rowCount = 0;
97 sql::JSONSQLWriter sqlWriter(isJSONPretty());
98 sql::SQLRowsetProcessor sqlRowsetProcessor(rowset, { &sqlWriter });
99
100 // Process rowset.
101 do {
102 rowCount = sqlRowsetProcessor.process(max_rows_ == 0 ? std::numeric_limits<size_t>::max() : max_rows_);
103 count++;
104 if (rowCount == 0)
105 break;
106
107 const auto output = sqlWriter.toString();
108 if (!output.empty()) {
109 WriteCallback writer(output);
110 auto newflow = session.create();
111 newflow->addAttribute(ResultRowCount, std::to_string(rowCount));
112 session.write(newflow, &writer);
113 session.transfer(newflow, s_success);
114 }
115 } while (rowCount > 0);
116}
117
118} /* namespace processors */
119} /* namespace minifi */

Callers

nothing calls this directly

Calls 10

prepareStatementMethod · 0.80
to_stringFunction · 0.50
executeMethod · 0.45
processMethod · 0.45
toStringMethod · 0.45
emptyMethod · 0.45
createMethod · 0.45
addAttributeMethod · 0.45
writeMethod · 0.45
transferMethod · 0.45

Tested by

no test coverage detected