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::QueryGraphEdges Class Reference

The QueryGraph contains edges between relations and allows edges to be created/queried. More...

#include <duckdb.hpp>

Collaboration diagram for duckdb::QueryGraphEdges:

Classes

struct  QueryEdge
 Contains a node with info about neighboring relations and child edge infos. More...

Public Member Functions

string ToString () const
void Print ()
const vector< reference< NeighborInfo > > GetConnections (JoinRelationSet &node, JoinRelationSet &other) const
 Returns a connection if there is an edge that connects these two sets, or nullptr otherwise.
const vector< idx_t > GetNeighbors (JoinRelationSet &node, unordered_set< idx_t > &exclusion_set) const
void EnumerateNeighbors (JoinRelationSet &node, const std::function< bool(NeighborInfo &)> &callback) const
 Enumerate all neighbors of a given JoinRelationSet node.
void CreateEdge (JoinRelationSet &left, JoinRelationSet &right, optional_ptr< FilterInfo > info)
 Create an edge in the edge_set.

Private Member Functions

optional_ptr< QueryEdge > GetQueryEdge (JoinRelationSet &left)
 Get the QueryEdge of a specific node.
void EnumerateNeighborsDFS (JoinRelationSet &node, reference< QueryEdge > info, idx_t index, const std::function< bool(NeighborInfo &)> &callback) const

Private Attributes

QueryEdge root

Detailed Description

The QueryGraph contains edges between relations and allows edges to be created/queried.

Member Function Documentation

◆ ToString()

string duckdb::QueryGraphEdges::ToString ( ) const
312748 {
312749 return QueryEdgeToString(&root, {});
312750}

◆ Print()

void duckdb::QueryGraphEdges::Print ( )
312752 {
312753 Printer::Print(ToString());
312754}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556

◆ GetConnections()

const vector< reference< NeighborInfo > > duckdb::QueryGraphEdges::GetConnections ( JoinRelationSet & node,
JoinRelationSet & other ) const

Returns a connection if there is an edge that connects these two sets, or nullptr otherwise.

312846 {
312847 vector<reference<NeighborInfo>> connections;
312848 EnumerateNeighbors(node, [&](NeighborInfo &info) -> bool {
312849 if (JoinRelationSet::IsSubset(other, *info.neighbor)) {
312850 connections.push_back(info);
312851 }
312852 return false;
312853 });
312854 return connections;
312855}
void EnumerateNeighbors(JoinRelationSet &node, const std::function< bool(NeighborInfo &)> &callback) const
Enumerate all neighbors of a given JoinRelationSet node.
Definition duckdb.cpp:312815
static bool IsSubset(JoinRelationSet &super, JoinRelationSet &sub)
Returns true if sub is a subset of super.
Definition duckdb.cpp:312070
Here is the call graph for this function:

◆ GetNeighbors()

const vector< idx_t > duckdb::QueryGraphEdges::GetNeighbors ( JoinRelationSet & node,
unordered_set< idx_t > & exclusion_set ) const

Enumerate the neighbors of a specific node that do not belong to any of the exclusion_set. Note that if a neighbor has multiple nodes, this function will return the lowest entry in that set.

312831 {
312832 unordered_set<idx_t> result;
312833 EnumerateNeighbors(node, [&](NeighborInfo &info) -> bool {
312834 if (!JoinRelationSetIsExcluded(info.neighbor, exclusion_set)) {
312835 // add the smallest node of the neighbor to the set
312836 result.insert(info.neighbor->relations[0]);
312837 }
312838 return false;
312839 });
312840 vector<idx_t> neighbors;
312841 neighbors.insert(neighbors.end(), result.begin(), result.end());
312842 return neighbors;
312843}
static bool JoinRelationSetIsExcluded(optional_ptr< JoinRelationSet > node, unordered_set< idx_t > &exclusion_set)
Returns true if a JoinRelationSet is banned by the list of exclusion_set, false otherwise.
Definition duckdb.cpp:312827
Here is the call graph for this function:

◆ EnumerateNeighbors()

void duckdb::QueryGraphEdges::EnumerateNeighbors ( JoinRelationSet & node,
const std::function< bool(NeighborInfo &)> & callback ) const

Enumerate all neighbors of a given JoinRelationSet node.

312816 {
312817 for (idx_t j = 0; j < node.count; j++) {
312818 auto iter = root.children.find(node.relations[j]);
312819 if (iter != root.children.end()) {
312820 reference<QueryEdge> new_info = *iter->second;
312821 EnumerateNeighborsDFS(node, new_info, j + 1, callback);
312822 }
312823 }
312824}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the caller graph for this function:

◆ CreateEdge()

void duckdb::QueryGraphEdges::CreateEdge ( JoinRelationSet & left,
JoinRelationSet & right,
optional_ptr< FilterInfo > info )

Create an edge in the edge_set.

312774 {
312775 D_ASSERT(left.count > 0 && right.count > 0);
312776 // find the EdgeInfo corresponding to the left set
312777 auto info = GetQueryEdge(left);
312778 // now insert the edge to the right relation, if it does not exist
312779 for (idx_t i = 0; i < info->neighbors.size(); i++) {
312780 if (info->neighbors[i]->neighbor == &right) {
312781 if (filter_info) {
312782 // neighbor already exists just add the filter, if we have any
312783 info->neighbors[i]->filters.push_back(filter_info);
312784 }
312785 return;
312786 }
312787 }
312788 // neighbor does not exist, create it
312789 auto n = make_uniq<NeighborInfo>(&right);
312790 // if the edge represents a cross product, filter_info is null. The easiest way then to determine
312791 // if an edge is for a cross product is if the filters are empty
312792 if (info && filter_info) {
312793 n->filters.push_back(filter_info);
312794 }
312795 info->neighbors.push_back(std::move(n));
312796}
optional_ptr< QueryEdge > GetQueryEdge(JoinRelationSet &left)
Get the QueryEdge of a specific node.
Definition duckdb.cpp:312757
Here is the call graph for this function:

◆ GetQueryEdge()

optional_ptr< QueryEdge > duckdb::QueryGraphEdges::GetQueryEdge ( JoinRelationSet & left)
private

Get the QueryEdge of a specific node.

312757 {
312758 D_ASSERT(left.count > 0);
312759 // find the EdgeInfo corresponding to the left set
312760 optional_ptr<QueryEdge> info(&root);
312761 for (idx_t i = 0; i < left.count; i++) {
312762 auto entry = info.get()->children.find(left.relations[i]);
312763 if (entry == info.get()->children.end()) {
312764 // node not found, create it
312765 auto insert_it = info.get()->children.insert(make_pair(left.relations[i], make_uniq<QueryEdge>()));
312766 entry = insert_it.first;
312767 }
312768 // move to the next node
312769 info = entry->second;
312770 }
312771 return info;
312772}
Here is the caller graph for this function:

◆ EnumerateNeighborsDFS()

void duckdb::QueryGraphEdges::EnumerateNeighborsDFS ( JoinRelationSet & node,
reference< QueryEdge > info,
idx_t index,
const std::function< bool(NeighborInfo &)> & callback ) const
private
312799 {
312800 for (auto &neighbor : info.get().neighbors) {
312801 if (callback(*neighbor)) {
312802 return;
312803 }
312804 }
312805
312806 for (idx_t node_index = index; node_index < node.count; ++node_index) {
312807 auto iter = info.get().children.find(node.relations[node_index]);
312808 if (iter != info.get().children.end()) {
312809 reference<QueryEdge> new_info = *iter->second;
312810 EnumerateNeighborsDFS(node, new_info, node_index + 1, callback);
312811 }
312812 }
312813}

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