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

MetaPipeline represents a set of pipelines that all have the same sink. More...

Inheritance diagram for duckdb::MetaPipeline:
Collaboration diagram for duckdb::MetaPipeline:

Public Member Functions

 MetaPipeline (Executor &executor, PipelineBuildState &state, optional_ptr< PhysicalOperator > sink, MetaPipelineType type=MetaPipelineType::REGULAR)
 Create a MetaPipeline with the given sink.
Executor & GetExecutor () const
 Get the Executor for this MetaPipeline.
PipelineBuildState & GetState () const
 Get the PipelineBuildState for this MetaPipeline.
optional_ptr< PhysicalOperator > GetSink () const
 Get the sink operator for this MetaPipeline.
optional_ptr< Pipeline > GetParent () const
 Get the parent pipeline.
shared_ptr< Pipeline > & GetBasePipeline ()
 Get the initial pipeline of this MetaPipeline.
void GetPipelines (vector< shared_ptr< Pipeline > > &result, bool recursive)
 Get the pipelines of this MetaPipeline.
void GetMetaPipelines (vector< shared_ptr< MetaPipeline > > &result, bool recursive, bool skip)
 Get the MetaPipeline children of this MetaPipeline.
MetaPipeline & GetLastChild ()
 Recursively gets the last child added.
const reference_map_t< Pipeline, vector< reference< Pipeline > > > & GetDependencies () const
 Get the dependencies of the Pipelines of this MetaPipeline.
MetaPipelineType Type () const
 Whether the sink of this pipeline is a join build.
bool HasRecursiveCTE () const
 Whether this MetaPipeline has a recursive CTE.
void SetRecursiveCTE ()
 Set the flag that this MetaPipeline is a recursive CTE pipeline.
void AssignNextBatchIndex (Pipeline &pipeline)
 Assign a batch index to the given pipeline.
vector< shared_ptr< Pipeline > > AddDependenciesFrom (Pipeline &dependant, const Pipeline &start, bool including)
void AddRecursiveDependencies (const vector< shared_ptr< Pipeline > > &new_dependencies, const MetaPipeline &last_child)
 Recursively makes all children of this MetaPipeline depend on the given Pipeline.
void AddFinishEvent (Pipeline &pipeline)
 Make sure that the given pipeline has its own PipelineFinishEvent (e.g., for IEJoin - double Finalize).
bool HasFinishEvent (Pipeline &pipeline) const
 Whether the pipeline needs its own PipelineFinishEvent.
optional_ptr< Pipeline > GetFinishGroup (Pipeline &pipeline) const
 Whether this pipeline is part of a PipelineFinishEvent.
void Build (PhysicalOperator &op)
 Build the MetaPipeline with 'op' as the first operator (excl. the shared sink).
void Ready () const
 Ready all the pipelines (recursively).
Pipeline & CreatePipeline ()
 Create an empty pipeline within this MetaPipeline.
Pipeline & CreateUnionPipeline (Pipeline &current, bool order_matters)
 Create a union pipeline (clone of 'current').
void CreateChildPipeline (Pipeline &current, PhysicalOperator &op, Pipeline &last_pipeline)
MetaPipeline & CreateChildMetaPipeline (Pipeline &current, PhysicalOperator &op, MetaPipelineType type=MetaPipelineType::REGULAR)
 Create a MetaPipeline child that 'current' depends on.
Public Member Functions inherited from duckdb::enable_shared_from_this< MetaPipeline >
shared_ptr< MetaPipeline > shared_from_this ()

Private Attributes

Executor & executor
 The executor for all MetaPipelines in the query plan.
PipelineBuildState & state
 The PipelineBuildState for all MetaPipelines in the query plan.
optional_ptr< Pipeline > parent
 Parent pipeline (optional).
optional_ptr< PhysicalOperator > sink
 The sink of all pipelines within this MetaPipeline.
MetaPipelineType type
 The type of this MetaPipeline (regular, join build).
bool recursive_cte
 Whether this MetaPipeline is a the recursive pipeline of a recursive CTE.
vector< shared_ptr< Pipeline > > pipelines
 All pipelines with a different source, but the same sink.
reference_map_t< Pipeline, vector< reference< Pipeline > > > pipeline_dependencies
 Dependencies of Pipelines of this MetaPipeline.
vector< shared_ptr< MetaPipeline > > children
 Other MetaPipelines that this MetaPipeline depends on.
idx_t next_batch_index
 Next batch index.
reference_set_t< Pipeline > finish_pipelines
 Pipelines (other than the base pipeline) that need their own PipelineFinishEvent (e.g., for IEJoin).
reference_map_t< Pipeline, Pipeline & > finish_map
 Mapping from pipeline (e.g., child or union) to finish pipeline.

Additional Inherited Members

Protected Member Functions inherited from duckdb::enable_shared_from_this< MetaPipeline >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Detailed Description

MetaPipeline represents a set of pipelines that all have the same sink.

Constructor & Destructor Documentation

◆ MetaPipeline()

duckdb::MetaPipeline::MetaPipeline ( Executor & executor,
PipelineBuildState & state,
optional_ptr< PhysicalOperator > sink,
MetaPipelineType type = MetaPipelineType::REGULAR )

Create a MetaPipeline with the given sink.

We follow these rules when building:

  1. For joins, build out the blocking side before going down the probe side
    • The current streaming pipeline will have a dependency on it (dependency across MetaPipelines)
    • Unions of this streaming pipeline will automatically inherit this dependency
  2. Build child pipelines last (e.g., Hash Join becomes source after probe is done: scan HT for FULL OUTER JOIN)
    • 'last' means after building out all other pipelines associated with this operator
    • The child pipeline automatically has dependencies (within this MetaPipeline) on:
      • The 'current' streaming pipeline
      • And all pipelines that were added to the MetaPipeline after 'current'
329288 : executor(executor_p), state(state_p), sink(sink_p), type(type_p), recursive_cte(false), next_batch_index(0) {
329289 CreatePipeline();
329290}
Pipeline & CreatePipeline()
Create an empty pipeline within this MetaPipeline.
Definition duckdb.cpp:329391
bool recursive_cte
Whether this MetaPipeline is a the recursive pipeline of a recursive CTE.
Definition duckdb.cpp:60722
idx_t next_batch_index
Next batch index.
Definition duckdb.cpp:60730
optional_ptr< PhysicalOperator > sink
The sink of all pipelines within this MetaPipeline.
Definition duckdb.cpp:60718
MetaPipelineType type
The type of this MetaPipeline (regular, join build).
Definition duckdb.cpp:60720
Executor & executor
The executor for all MetaPipelines in the query plan.
Definition duckdb.cpp:60712
PipelineBuildState & state
The PipelineBuildState for all MetaPipelines in the query plan.
Definition duckdb.cpp:60714
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ GetExecutor()

Executor & duckdb::MetaPipeline::GetExecutor ( ) const

Get the Executor for this MetaPipeline.

329292 {
329293 return executor;
329294}

◆ GetState()

PipelineBuildState & duckdb::MetaPipeline::GetState ( ) const

Get the PipelineBuildState for this MetaPipeline.

329296 {
329297 return state;
329298}

◆ GetSink()

optional_ptr< PhysicalOperator > duckdb::MetaPipeline::GetSink ( ) const

Get the sink operator for this MetaPipeline.

329300 {
329301 return sink;
329302}

◆ GetParent()

optional_ptr< Pipeline > duckdb::MetaPipeline::GetParent ( ) const

Get the parent pipeline.

329304 {
329305 return parent;
329306}
optional_ptr< Pipeline > parent
Parent pipeline (optional).
Definition duckdb.cpp:60716

◆ GetBasePipeline()

shared_ptr< Pipeline > & duckdb::MetaPipeline::GetBasePipeline ( )

Get the initial pipeline of this MetaPipeline.

329308 {
329309 return pipelines[0];
329310}
vector< shared_ptr< Pipeline > > pipelines
All pipelines with a different source, but the same sink.
Definition duckdb.cpp:60724

◆ GetPipelines()

void duckdb::MetaPipeline::GetPipelines ( vector< shared_ptr< Pipeline > > & result,
bool recursive )

Get the pipelines of this MetaPipeline.

329312 {
329313 result.insert(result.end(), pipelines.begin(), pipelines.end());
329314 if (recursive) {
329315 for (auto &child : children) {
329316 child->GetPipelines(result, true);
329317 }
329318 }
329319}
vector< shared_ptr< MetaPipeline > > children
Other MetaPipelines that this MetaPipeline depends on.
Definition duckdb.cpp:60728

◆ GetMetaPipelines()

void duckdb::MetaPipeline::GetMetaPipelines ( vector< shared_ptr< MetaPipeline > > & result,
bool recursive,
bool skip )

Get the MetaPipeline children of this MetaPipeline.

329321 {
329322 if (!skip) {
329323 result.push_back(shared_from_this());
329324 }
329325 for (auto &child : children) {
329326 result.push_back(child);
329327 if (recursive) {
329328 child->GetMetaPipelines(result, true, true);
329329 }
329330 }
329331}
Here is the caller graph for this function:

◆ GetLastChild()

MetaPipeline & duckdb::MetaPipeline::GetLastChild ( )

Recursively gets the last child added.

329333 {
329334 if (children.empty()) {
329335 return *this;
329336 }
329337 reference<const vector<shared_ptr<MetaPipeline>>> current_children = children;
329338 while (!current_children.get().back()->children.empty()) {
329339 current_children = current_children.get().back()->children;
329340 }
329341 return *current_children.get().back();
329342}
Here is the call graph for this function:

◆ GetDependencies()

const reference_map_t< Pipeline, vector< reference< Pipeline > > > & duckdb::MetaPipeline::GetDependencies ( ) const

Get the dependencies of the Pipelines of this MetaPipeline.

329344 {
329345 return pipeline_dependencies;
329346}
reference_map_t< Pipeline, vector< reference< Pipeline > > > pipeline_dependencies
Dependencies of Pipelines of this MetaPipeline.
Definition duckdb.cpp:60726

◆ Type()

MetaPipelineType duckdb::MetaPipeline::Type ( ) const

Whether the sink of this pipeline is a join build.

329348 {
329349 return type;
329350}

◆ HasRecursiveCTE()

bool duckdb::MetaPipeline::HasRecursiveCTE ( ) const

Whether this MetaPipeline has a recursive CTE.

329352 {
329353 return recursive_cte;
329354}

◆ SetRecursiveCTE()

void duckdb::MetaPipeline::SetRecursiveCTE ( )

Set the flag that this MetaPipeline is a recursive CTE pipeline.

329356 {
329357 recursive_cte = true;
329358}

◆ AssignNextBatchIndex()

void duckdb::MetaPipeline::AssignNextBatchIndex ( Pipeline & pipeline)

Assign a batch index to the given pipeline.

329360 {
329361 pipeline.base_batch_index = next_batch_index++ * PipelineBuildState::BATCH_INCREMENT;
329362}
static constexpr idx_t BATCH_INCREMENT
How much to increment batch indexes when multiple pipelines share the same source.
Definition duckdb.hpp:26848

◆ AddDependenciesFrom()

vector< shared_ptr< Pipeline > > duckdb::MetaPipeline::AddDependenciesFrom ( Pipeline & dependant,
const Pipeline & start,
bool including )

Let 'dependant' depend on all pipeline that were created since 'start', where 'including' determines whether 'start' is added to the dependencies

329398 {
329399 // find 'start'
329400 auto it = pipelines.begin();
329401 for (; !RefersToSameObject(**it, start); it++) {
329402 }
329403
329404 if (!including) {
329405 it++;
329406 }
329407
329408 // collect pipelines that were created from then
329409 vector<shared_ptr<Pipeline>> created_pipelines;
329410 for (; it != pipelines.end(); it++) {
329411 if (RefersToSameObject(**it, dependant)) {
329412 // cannot depend on itself
329413 continue;
329414 }
329415 created_pipelines.push_back(*it);
329416 }
329417
329418 // add them to the dependencies
329419 auto &explicit_deps = pipeline_dependencies[dependant];
329420 for (auto &created_pipeline : created_pipelines) {
329421 explicit_deps.push_back(*created_pipeline);
329422 }
329423
329424 return created_pipelines;
329425}
bool RefersToSameObject(const reference< T > &a, const reference< T > &b)
Returns whether or not two reference wrappers refer to the same object.
Definition duckdb.hpp:2191
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddRecursiveDependencies()

void duckdb::MetaPipeline::AddRecursiveDependencies ( const vector< shared_ptr< Pipeline > > & new_dependencies,
const MetaPipeline & last_child )

Recursively makes all children of this MetaPipeline depend on the given Pipeline.

329437 {
329438 if (recursive_cte) {
329439 return; // let's not burn our fingers on this for now
329440 }
329441
329442 vector<shared_ptr<MetaPipeline>> child_meta_pipelines;
329443 this->GetMetaPipelines(child_meta_pipelines, true, false);
329444
329445 // find the meta pipeline that has the same sink as 'pipeline'
329446 auto it = child_meta_pipelines.begin();
329447 for (; !RefersToSameObject(last_child, **it); it++) {
329448 }
329449 D_ASSERT(it != child_meta_pipelines.end());
329450
329451 // skip over it
329452 it++;
329453
329454 // we try to limit the performance impact of these dependencies on smaller workloads,
329455 // by only adding the dependencies if the source operator can likely keep all threads busy
329456 const auto thread_count = NumericCast<idx_t>(TaskScheduler::GetScheduler(executor.context).NumberOfThreads());
329457 for (; it != child_meta_pipelines.end(); it++) {
329458 for (auto &pipeline : it->get()->pipelines) {
329459 if (!PipelineExceedsThreadCount(*pipeline, thread_count)) {
329460 continue;
329461 }
329462 auto &pipeline_deps = pipeline_dependencies[*pipeline];
329463 for (auto &new_dependency : new_dependencies) {
329464 if (!PipelineExceedsThreadCount(*new_dependency, thread_count)) {
329465 continue;
329466 }
329467 pipeline_deps.push_back(*new_dependency);
329468 }
329469 }
329470 }
329471}
void GetMetaPipelines(vector< shared_ptr< MetaPipeline > > &result, bool recursive, bool skip)
Get the MetaPipeline children of this MetaPipeline.
Definition duckdb.cpp:329321
Here is the call graph for this function:

◆ AddFinishEvent()

void duckdb::MetaPipeline::AddFinishEvent ( Pipeline & pipeline)

Make sure that the given pipeline has its own PipelineFinishEvent (e.g., for IEJoin - double Finalize).

329473 {
329474 D_ASSERT(finish_pipelines.find(pipeline) == finish_pipelines.end());
329475 finish_pipelines.insert(pipeline);
329476
329477 // add all pipelines that were added since 'pipeline' was added (including 'pipeline') to the finish group
329478 auto it = pipelines.begin();
329479 for (; !RefersToSameObject(**it, pipeline); it++) {
329480 }
329481 it++;
329482 for (; it != pipelines.end(); it++) {
329483 finish_map.emplace(**it, pipeline);
329484 }
329485}
reference_map_t< Pipeline, Pipeline & > finish_map
Mapping from pipeline (e.g., child or union) to finish pipeline.
Definition duckdb.cpp:60734
reference_set_t< Pipeline > finish_pipelines
Pipelines (other than the base pipeline) that need their own PipelineFinishEvent (e....
Definition duckdb.cpp:60732
Here is the call graph for this function:

◆ HasFinishEvent()

bool duckdb::MetaPipeline::HasFinishEvent ( Pipeline & pipeline) const

Whether the pipeline needs its own PipelineFinishEvent.

329487 {
329488 return finish_pipelines.find(pipeline) != finish_pipelines.end();
329489}

◆ GetFinishGroup()

optional_ptr< Pipeline > duckdb::MetaPipeline::GetFinishGroup ( Pipeline & pipeline) const

Whether this pipeline is part of a PipelineFinishEvent.

329491 {
329492 auto it = finish_map.find(pipeline);
329493 return it == finish_map.end() ? nullptr : &it->second;
329494}

◆ Build()

void duckdb::MetaPipeline::Build ( PhysicalOperator & op)

Build the MetaPipeline with 'op' as the first operator (excl. the shared sink).

329364 {
329365 D_ASSERT(pipelines.size() == 1);
329366 D_ASSERT(children.empty());
329367 op.BuildPipelines(*pipelines.back(), *this);
329368}

◆ Ready()

void duckdb::MetaPipeline::Ready ( ) const

Ready all the pipelines (recursively).

329370 {
329371 for (auto &pipeline : pipelines) {
329372 pipeline->Ready();
329373 }
329374 for (auto &child : children) {
329375 child->Ready();
329376 }
329377}

◆ CreatePipeline()

Pipeline & duckdb::MetaPipeline::CreatePipeline ( )

Create an empty pipeline within this MetaPipeline.

329391 {
329392 pipelines.emplace_back(make_shared_ptr<Pipeline>(executor));
329393 state.SetPipelineSink(*pipelines.back(), sink, next_batch_index++);
329394 return *pipelines.back();
329395}
Here is the caller graph for this function:

◆ CreateUnionPipeline()

Pipeline & duckdb::MetaPipeline::CreateUnionPipeline ( Pipeline & current,
bool order_matters )

Create a union pipeline (clone of 'current').

329496 {
329497 // create the union pipeline (batch index 0, should be set correctly afterwards)
329498 auto &union_pipeline = CreatePipeline();
329499 state.SetPipelineOperators(union_pipeline, state.GetPipelineOperators(current));
329500 state.SetPipelineSink(union_pipeline, sink, 0);
329501
329502 // 'union_pipeline' inherits ALL dependencies of 'current' (within this MetaPipeline, and across MetaPipelines)
329503 union_pipeline.dependencies = current.dependencies;
329504 auto it = pipeline_dependencies.find(current);
329505 if (it != pipeline_dependencies.end()) {
329506 pipeline_dependencies[union_pipeline] = it->second;
329507 }
329508
329509 if (order_matters) {
329510 // if we need to preserve order, or if the sink is not parallel, we set a dependency
329511 pipeline_dependencies[union_pipeline].push_back(current);
329512 }
329513
329514 return union_pipeline;
329515}
Here is the call graph for this function:

◆ CreateChildPipeline()

void duckdb::MetaPipeline::CreateChildPipeline ( Pipeline & current,
PhysicalOperator & op,
Pipeline & last_pipeline )

Create a child pipeline op 'current' starting at 'op', where 'last_pipeline' is the last pipeline added before building out 'current'

329517 {
329518 // rule 2: 'current' must be fully built (down to the source) before creating the child pipeline
329519 D_ASSERT(current.source);
329520
329521 // create the child pipeline (same batch index)
329522 pipelines.emplace_back(state.CreateChildPipeline(executor, current, op));
329523 auto &child_pipeline = *pipelines.back();
329524 child_pipeline.base_batch_index = current.base_batch_index;
329525
329526 // child pipeline has a dependency (within this MetaPipeline on all pipelines that were scheduled
329527 // between 'current' and now (including 'current') - set them up
329528 pipeline_dependencies[child_pipeline].push_back(current);
329529 AddDependenciesFrom(child_pipeline, last_pipeline, false);
329530 D_ASSERT(pipeline_dependencies.find(child_pipeline) != pipeline_dependencies.end());
329531}
vector< shared_ptr< Pipeline > > AddDependenciesFrom(Pipeline &dependant, const Pipeline &start, bool including)
Definition duckdb.cpp:329397
Here is the call graph for this function:

◆ CreateChildMetaPipeline()

MetaPipeline & duckdb::MetaPipeline::CreateChildMetaPipeline ( Pipeline & current,
PhysicalOperator & op,
MetaPipelineType type = MetaPipelineType::REGULAR )

Create a MetaPipeline child that 'current' depends on.

329379 {
329380 children.push_back(make_shared_ptr<MetaPipeline>(executor, state, &op, type));
329381 auto &child_meta_pipeline = *children.back().get();
329382 // store the parent
329383 child_meta_pipeline.parent = &current;
329384 // child MetaPipeline must finish completely before this MetaPipeline can start
329385 current.AddDependency(child_meta_pipeline.GetBasePipeline());
329386 // child meta pipeline is part of the recursive CTE too
329387 child_meta_pipeline.recursive_cte = recursive_cte;
329388 return child_meta_pipeline;
329389}
Here is the call graph for this function:

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