MCPcopy Create free account
hub / github.com/apache/impala / Send

Method Send

be/src/exec/blocking-plan-root-sink.cc:46–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46Status BlockingPlanRootSink::Send(RuntimeState* state, RowBatch* batch) {
47 SCOPED_TIMER(profile()->total_time_counter());
48 RETURN_IF_ERROR(PlanRootSink::UpdateAndCheckRowsProducedLimit(state, batch));
49 int current_batch_row = 0;
50
51 // Don't enter the loop if batch->num_rows() == 0; no point triggering the consumer with
52 // 0 rows to return. Be wary of ever returning 0-row batches to the client; some poorly
53 // written clients may not cope correctly with them. See IMPALA-4335.
54 while (current_batch_row < batch->num_rows()) {
55 unique_lock<mutex> l(lock_);
56 // Wait until the consumer gives us a result set to fill in, or the fragment
57 // instance has been cancelled.
58 while (results_ == nullptr && !state->is_cancelled()) {
59 SCOPED_TIMER(profile_->inactive_timer());
60 sender_cv_.Wait(l);
61 }
62 RETURN_IF_CANCELLED(state);
63
64 // Otherwise the consumer is ready. Fill out the rows.
65 DCHECK(results_ != nullptr);
66 int num_to_fetch = batch->num_rows() - current_batch_row;
67 if (num_rows_requested_ > 0) num_to_fetch = min(num_to_fetch, num_rows_requested_);
68 // Debug action before AddBatch is called.
69 RETURN_IF_ERROR(DebugAction(state->query_options(), "BPRS_BEFORE_ADD_ROWS"));
70 {
71 SCOPED_TIMER(create_result_set_timer_);
72 RETURN_IF_ERROR(results_->AddRows(
73 output_expr_evals_, batch, current_batch_row, num_to_fetch));
74 }
75 current_batch_row += num_to_fetch;
76 // Prevent expr result allocations from accumulating.
77 expr_results_pool_->Clear();
78 // Signal the consumer.
79 results_ = nullptr;
80 consumer_cv_.NotifyAll();
81 }
82 rows_sent_counter_->Add(batch->num_rows());
83 return Status::OK();
84}
85
86Status BlockingPlanRootSink::FlushFinal(RuntimeState* state) {
87 SCOPED_TIMER(profile()->total_time_counter());

Callers

nothing calls this directly

Calls 12

minFunction · 0.85
DebugActionFunction · 0.85
OKFunction · 0.85
total_time_counterMethod · 0.80
inactive_timerMethod · 0.80
NotifyAllMethod · 0.80
num_rowsMethod · 0.45
is_cancelledMethod · 0.45
WaitMethod · 0.45
AddRowsMethod · 0.45
ClearMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected