2020namespace doris ::pipeline {
2121
2222Operator::Operator (OperatorTemplate* operator_template)
23- : _operator_template(operator_template), _limit(-1 ), _is_closed(false ) {}
23+ : _operator_template(operator_template),
24+ _num_rows_returned (0 ),
25+ _limit(-1 ),
26+ _is_closed(false ) {}
2427
2528bool Operator::is_sink () const {
2629 return _operator_template->is_sink ();
@@ -31,14 +34,30 @@ bool Operator::is_source() const {
3134}
3235
3336Status Operator::init (const ExecNode* exec_node, RuntimeState* state) {
34- _runtime_profile.reset (new RuntimeProfile (" Operator" ));
35- _runtime_profile->set_metadata (_operator_template->id ());
37+ _runtime_profile.reset (new RuntimeProfile (_operator_template->get_name ()));
38+ _rows_returned_counter = ADD_COUNTER (_runtime_profile, " RowsReturned" , TUnit::UNIT );
39+ _rows_returned_rate = runtime_profile ()->add_derived_counter (
40+ ExecNode::ROW_THROUGHPUT_COUNTER , TUnit::UNIT_PER_SECOND ,
41+ std::bind<int64_t >(&RuntimeProfile::units_per_second, _rows_returned_counter,
42+ runtime_profile ()->total_time_counter ()),
43+ " " );
3644 if (exec_node && exec_node->limit () >= 0 ) {
3745 _limit = exec_node->limit ();
3846 }
3947 return Status::OK ();
4048}
4149
50+ Status Operator::link_profile (RuntimeProfile* parent) {
51+ if (!_runtime_profile) {
52+ return Status::InternalError (" link profile error" );
53+ }
54+ if (_child) {
55+ RETURN_IF_ERROR (_child->link_profile (_runtime_profile.get ()));
56+ }
57+ parent->add_child (_runtime_profile.get (), true , nullptr );
58+ return Status::OK ();
59+ }
60+
4261Status Operator::prepare (RuntimeState* state) {
4362 _mem_tracker = std::make_unique<MemTracker>(" Operator:" + _runtime_profile->name (),
4463 _runtime_profile.get ());
@@ -66,6 +85,9 @@ Status Operator::close(RuntimeState* state) {
6685 if (_operator_template->exec_node ()) {
6786 _operator_template->exec_node ()->close_self (state);
6887 }
88+ if (_rows_returned_counter != nullptr ) {
89+ COUNTER_SET (_rows_returned_counter, _num_rows_returned);
90+ }
6991 return Status::OK ();
7092}
7193
0 commit comments