forked from cmu-db/peloton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperator_expression.cpp
64 lines (54 loc) · 1.6 KB
/
operator_expression.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//===----------------------------------------------------------------------===//
//
// Peloton
//
// op_expression.cpp
//
// Identification: src/optimizer/op_expression.cpp
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include "optimizer/operator_expression.h"
#include <limits>
namespace peloton {
namespace optimizer {
//===--------------------------------------------------------------------===//
// Operator Expression
//===--------------------------------------------------------------------===//
OperatorExpression::OperatorExpression(Operator op) : op(op) {}
void OperatorExpression::PushChild(std::shared_ptr<OperatorExpression> op) {
children.push_back(op);
}
void OperatorExpression::PopChild() { children.pop_back(); }
const std::vector<std::shared_ptr<OperatorExpression>>
&OperatorExpression::Children() const {
return children;
}
const Operator &OperatorExpression::Op() const { return op; }
const std::string OperatorExpression::GetInfo() const {
std::string info = "{";
{
info += "\"Op\":";
info += "\"" + op.GetName() + "\",";
if (!children.empty()) {
info += "\"Children\":[";
{
bool is_first = true;
for (const auto &child : children) {
if (is_first == true) {
is_first = false;
} else {
info += ",";
}
info += child->GetInfo();
}
}
info += "]";
}
}
info += '}';
return info;
}
} // namespace optimizer
} // namespace peloton