Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::SetOperationNode Class Reference
Inheritance diagram for duckdb::SetOperationNode:
Collaboration diagram for duckdb::SetOperationNode:

Public Member Functions

string ToString () const override
 Convert the query node to a string.
bool Equals (const QueryNode *other) const override
unique_ptr< QueryNode > Copy () const override
 Create a copy of this SelectNode.
void Serialize (Serializer &serializer) const override
 SetOperationNode (SetOperationType setop_type, unique_ptr< QueryNode > left, unique_ptr< QueryNode > right, vector< unique_ptr< QueryNode > > children, bool setop_all)
unique_ptr< QueryNode > SerializeChildNode (Serializer &serializer, idx_t index) const
bool SerializeChildList (Serializer &serializer) const
Public Member Functions inherited from duckdb::QueryNode
 QueryNode (QueryNodeType type)
string ResultModifiersToString () const
void AddDistinct ()
 Adds a distinct modifier to the query node.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< QueryNode > Deserialize (Deserializer &source)
Static Public Member Functions inherited from duckdb::QueryNode
static unique_ptr< QueryNode > Deserialize (Deserializer &deserializer)

Public Attributes

SetOperationType setop_type = SetOperationType::NONE
 The type of set operation.
bool setop_all = false
 whether the ALL modifier was used or not
vector< unique_ptr< QueryNode > > children
 The children of the set operation.
Public Attributes inherited from duckdb::QueryNode
QueryNodeType type
 The type of the query node, either SetOperation or Select.
vector< unique_ptr< ResultModifier > > modifiers
 The set of result modifiers associated with this query node.
CommonTableExpressionMap cte_map
 CTEs (used by SelectNode and SetOperationNode).

Static Public Attributes

static constexpr const QueryNodeType TYPE = QueryNodeType::SET_OPERATION_NODE

Additional Inherited Members

Protected Member Functions inherited from duckdb::QueryNode
void CopyProperties (QueryNode &other) const
 Copy base QueryNode properties from another expression to this one, used in Copy method.

Constructor & Destructor Documentation

◆ SetOperationNode() [1/2]

duckdb::SetOperationNode::SetOperationNode ( )
348224 : QueryNode(QueryNodeType::SET_OPERATION_NODE) {
348225}

◆ SetOperationNode() [2/2]

duckdb::SetOperationNode::SetOperationNode ( SetOperationType setop_type,
unique_ptr< QueryNode > left,
unique_ptr< QueryNode > right,
vector< unique_ptr< QueryNode > > children,
bool setop_all )
348292 : QueryNode(QueryNodeType::SET_OPERATION_NODE), setop_type(setop_type), setop_all(setop_all) {
348293 if (children_p.empty()) {
348294 if (!left || !right) {
348295 throw SerializationException("Error deserializing SetOperationNode - left/right or children must be set");
348296 }
348297 children.push_back(std::move(left));
348298 children.push_back(std::move(right));
348299 } else {
348300 if (left || right) {
348301 throw SerializationException("Error deserializing SetOperationNode - left/right or children must be set");
348302 }
348303 children = std::move(children_p);
348304 }
348305 if (children.size() < 2) {
348306 throw SerializationException("SetOperationNode must have at least two children");
348307 }
348308}
vector< unique_ptr< QueryNode > > children
The children of the set operation.
Definition duckdb.cpp:297112
bool setop_all
whether the ALL modifier was used or not
Definition duckdb.cpp:297110
SetOperationType setop_type
The type of set operation.
Definition duckdb.cpp:297108

Member Function Documentation

◆ ToString()

string duckdb::SetOperationNode::ToString ( ) const
overridevirtual

Convert the query node to a string.

Implements duckdb::QueryNode.

348227 {
348228 string result;
348229 result = cte_map.ToString();
348230 result += "(" + children[0]->ToString() + ") ";
348231
348232 for (idx_t i = 1; i < children.size(); i++) {
348233 switch (setop_type) {
348234 case SetOperationType::UNION:
348235 result += setop_all ? "UNION ALL" : "UNION";
348236 break;
348237 case SetOperationType::UNION_BY_NAME:
348238 result += setop_all ? "UNION ALL BY NAME" : "UNION BY NAME";
348239 break;
348240 case SetOperationType::EXCEPT:
348241 result += setop_all ? "EXCEPT ALL" : "EXCEPT";
348242 break;
348243 case SetOperationType::INTERSECT:
348244 result += setop_all ? "INTERSECT ALL" : "INTERSECT";
348245 break;
348246 default:
348247 throw InternalException("Unsupported set operation type");
348248 }
348249 result += " (" + children[i]->ToString() + ")";
348250 }
348251 return result + ResultModifiersToString();
348252}
CommonTableExpressionMap cte_map
CTEs (used by SelectNode and SetOperationNode).
Definition duckdb.hpp:53582
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Equals()

bool duckdb::SetOperationNode::Equals ( const QueryNode * other) const
overridevirtual

Reimplemented from duckdb::QueryNode.

348254 {
348255 if (!QueryNode::Equals(other_p)) {
348256 return false;
348257 }
348258 if (this == other_p) {
348259 return true;
348260 }
348261 auto &other = other_p->Cast<SetOperationNode>();
348262 if (setop_type != other.setop_type) {
348263 return false;
348264 }
348265 if (setop_all != other.setop_all) {
348266 return false;
348267 }
348268 if (children.size() != other.children.size()) {
348269 return false;
348270 }
348271 for (idx_t i = 0; i < children.size(); i++) {
348272 if (!children[i]->Equals(other.children[i].get())) {
348273 return false;
348274 }
348275 }
348276 return true;
348277}

◆ Copy()

unique_ptr< QueryNode > duckdb::SetOperationNode::Copy ( ) const
overridevirtual

Create a copy of this SelectNode.

Implements duckdb::QueryNode.

348279 {
348280 auto result = make_uniq<SetOperationNode>();
348281 result->setop_type = setop_type;
348282 result->setop_all = setop_all;
348283 for (auto &child : children) {
348284 result->children.push_back(child->Copy());
348285 }
348286 this->CopyProperties(*result);
348287 return std::move(result);
348288}
void CopyProperties(QueryNode &other) const
Copy base QueryNode properties from another expression to this one, used in Copy method.
Definition duckdb.cpp:348602
Here is the call graph for this function:

◆ Serialize()

void duckdb::SetOperationNode::Serialize ( Serializer & serializer) const
overridevirtual

Serializes a QueryNode to a stand-alone binary blob Deserializes a blob back into a QueryNode

Reimplemented from duckdb::QueryNode.

419143 {
419144 QueryNode::Serialize(serializer);
419145 serializer.WriteProperty<SetOperationType>(200, "setop_type", setop_type);
419146 serializer.WritePropertyWithDefault<unique_ptr<QueryNode>>(201, "left", SerializeChildNode(serializer, 0));
419147 serializer.WritePropertyWithDefault<unique_ptr<QueryNode>>(202, "right", SerializeChildNode(serializer, 1));
419148 serializer.WritePropertyWithDefault<bool>(203, "setop_all", setop_all, true);
419149 if (serializer.ShouldSerialize(7)) {
419150 serializer.WritePropertyWithDefault<vector<unique_ptr<QueryNode>>>(204, "children", children);
419151 }
419152}

◆ Deserialize()

unique_ptr< QueryNode > duckdb::SetOperationNode::Deserialize ( Deserializer & source)
static
419154 {
419155 auto setop_type = deserializer.ReadProperty<SetOperationType>(200, "setop_type");
419156 auto left = deserializer.ReadPropertyWithDefault<unique_ptr<QueryNode>>(201, "left");
419157 auto right = deserializer.ReadPropertyWithDefault<unique_ptr<QueryNode>>(202, "right");
419158 auto setop_all = deserializer.ReadPropertyWithExplicitDefault<bool>(203, "setop_all", true);
419159 auto children = deserializer.ReadPropertyWithDefault<vector<unique_ptr<QueryNode>>>(204, "children");
419160 auto result = duckdb::unique_ptr<SetOperationNode>(new SetOperationNode(setop_type, std::move(left), std::move(right), std::move(children), setop_all));
419161 return std::move(result);
419162}

◆ SerializeChildNode()

unique_ptr< QueryNode > duckdb::SetOperationNode::SerializeChildNode ( Serializer & serializer,
idx_t index ) const
348310 {
348311 if (SerializeChildList(serializer)) {
348312 // serialize new version - we are serializing all children in the new "children" field
348313 return nullptr;
348314 }
348315 // backwards compatibility - we are targeting an older version
348316 // we need to serialize two children - "left" and "right"
348317 if (index == 0) {
348318 // for the left child, just directly emit the first child
348319 return children[0]->Copy();
348320 }
348321 if (index != 1) {
348322 throw InternalException("SerializeChildNode should have index 0 or 1");
348323 }
348324 vector<unique_ptr<QueryNode>> nodes;
348325 for (idx_t i = 1; i < children.size(); i++) {
348326 nodes.push_back(children[i]->Copy());
348327 }
348328 // for the right child we construct a new tree by generating the set operation over all of the nodes
348329 // we construct a balanced tree to avoid
348330 while (nodes.size() > 1) {
348331 vector<unique_ptr<QueryNode>> new_children;
348332 for (idx_t i = 0; i < nodes.size(); i += 2) {
348333 if (i + 1 == nodes.size()) {
348334 new_children.push_back(std::move(nodes[i]));
348335 } else {
348336 vector<unique_ptr<QueryNode>> empty_children;
348337 auto setop_node = make_uniq<SetOperationNode>(setop_type, std::move(nodes[i]), std::move(nodes[i + 1]),
348338 std::move(empty_children), setop_all);
348339 new_children.push_back(std::move(setop_node));
348340 }
348341 }
348342 nodes = std::move(new_children);
348343 }
348344 return std::move(nodes[0]);
348345}
unique_ptr< QueryNode > Copy() const override
Create a copy of this SelectNode.
Definition duckdb.cpp:348279

◆ SerializeChildList()

bool duckdb::SetOperationNode::SerializeChildList ( Serializer & serializer) const
348347 {
348348 return serializer.ShouldSerialize(7);
348349}

The documentation for this class was generated from the following file: