| 726 | } |
| 727 | |
| 728 | Status AnalyticEvalNode::GetNextOutputBatch( |
| 729 | RuntimeState* state, RowBatch* output_batch, bool* eos) { |
| 730 | SCOPED_TIMER(evaluation_timer_); |
| 731 | VLOG_FILE << id() << " GetNextOutputBatch: " << DebugStateString() |
| 732 | << " tuple pool size:" << curr_tuple_pool_->total_allocated_bytes(); |
| 733 | if (input_stream_->rows_returned() == input_stream_->num_rows()) { |
| 734 | *eos = true; |
| 735 | return Status::OK(); |
| 736 | } |
| 737 | |
| 738 | const int num_child_tuples = child(0)->row_desc()->tuple_descriptors().size(); |
| 739 | RowBatch input_batch(child(0)->row_desc(), output_batch->capacity(), mem_tracker()); |
| 740 | int64_t stream_idx = input_stream_->rows_returned(); |
| 741 | RETURN_IF_ERROR(input_stream_->GetNext(&input_batch, eos)); |
| 742 | for (int i = 0; i < input_batch.num_rows(); ++i) { |
| 743 | if (ReachedLimit()) break; |
| 744 | DCHECK(!output_batch->AtCapacity()); |
| 745 | DCHECK(!result_tuples_.empty()); |
| 746 | VLOG_ROW << id() << " Output row idx=" << stream_idx << " " << DebugStateString(true); |
| 747 | |
| 748 | // CopyRow works as expected: input_batch tuples form a prefix of output_batch |
| 749 | // tuples. |
| 750 | TupleRow* dest = output_batch->GetRow(output_batch->AddRow()); |
| 751 | input_batch.CopyRow(input_batch.GetRow(i), dest); |
| 752 | dest->SetTuple(num_child_tuples, result_tuples_.front().second); |
| 753 | output_batch->CommitLastRow(); |
| 754 | IncrementNumRowsReturned(1); |
| 755 | |
| 756 | // Remove the head of result_tuples_ if all rows using that evaluated tuple |
| 757 | // have been returned. |
| 758 | DCHECK_LE(stream_idx, result_tuples_.front().first); |
| 759 | if (stream_idx >= result_tuples_.front().first) result_tuples_.pop_front(); |
| 760 | ++stream_idx; |
| 761 | } |
| 762 | input_batch.TransferResourceOwnership(output_batch); |
| 763 | if (ReachedLimit()) *eos = true; |
| 764 | return Status::OK(); |
| 765 | } |
| 766 | |
| 767 | inline int64_t AnalyticEvalNode::NumOutputRowsReady() const { |
| 768 | if (result_tuples_.empty()) return 0; |
nothing calls this directly
no test coverage detected