1#include "duckdb/execution/physical_operator.hpp"
2
3#include "duckdb/common/string_util.hpp"
4#include "duckdb/main/client_context.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9string PhysicalOperator::ToString(idx_t depth) const {
10 string extra_info = StringUtil::Replace(ExtraRenderInformation(), "\n", " ");
11 StringUtil::RTrim(extra_info);
12 if (!extra_info.empty()) {
13 extra_info = "[" + extra_info + "]";
14 }
15 string result = PhysicalOperatorToString(type) + extra_info;
16 if (children.size() > 0) {
17 for (idx_t i = 0; i < children.size(); i++) {
18 result += "\n" + string(depth * 4, ' ');
19 auto &child = children[i];
20 result += child->ToString(depth + 1);
21 }
22 result += "";
23 }
24 return result;
25}
26
27PhysicalOperatorState::PhysicalOperatorState(PhysicalOperator *child) : finished(false) {
28 if (child) {
29 child->InitializeChunk(child_chunk);
30 child_state = child->GetOperatorState();
31 }
32}
33
34void PhysicalOperator::GetChunk(ClientContext &context, DataChunk &chunk, PhysicalOperatorState *state) {
35 if (context.interrupted) {
36 throw InterruptException();
37 }
38
39 chunk.Reset();
40 if (state->finished) {
41 return;
42 }
43
44 context.profiler.StartOperator(this);
45 GetChunkInternal(context, chunk, state);
46 context.profiler.EndOperator(chunk);
47
48 chunk.Verify();
49}
50
51void PhysicalOperator::Print() {
52 Printer::Print(ToString());
53}
54