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

PhysicalJoin represents the base class of the join operators. More...

Inheritance diagram for duckdb::PhysicalJoin:
Collaboration diagram for duckdb::PhysicalJoin:

Public Member Functions

 PhysicalJoin (PhysicalPlan &physical_plan, LogicalOperator &op, PhysicalOperatorType type, JoinType join_type, idx_t estimated_cardinality)
bool EmptyResultIfRHSIsEmpty () const
void BuildPipelines (Pipeline &current, MetaPipeline &meta_pipeline) override
vector< const_reference< PhysicalOperator > > GetSources () const override
OrderPreservationType SourceOrder () const override
 The type of order emitted by the operator (as a source).
OrderPreservationType OperatorOrder () const override
 The influence the operator has on order (insertion order means no influence).
bool SinkOrderDependent () const override
Public Member Functions inherited from duckdb::CachingPhysicalOperator
 CachingPhysicalOperator (PhysicalPlan &physical_plan, PhysicalOperatorType type, vector< LogicalType > types, idx_t estimated_cardinality)
OperatorResultType Execute (ExecutionContext &context, DataChunk &input, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const final
OperatorFinalizeResultType FinalExecute (ExecutionContext &context, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const final
bool RequiresFinalExecute () const final
Public Member Functions inherited from duckdb::PhysicalOperator
 PhysicalOperator (PhysicalPlan &physical_plan, PhysicalOperatorType type, vector< LogicalType > types, idx_t estimated_cardinality)
 PhysicalOperator (const PhysicalOperator &other)=delete
 Deleted copy constructors.
PhysicalOperator & operator= (const PhysicalOperator &)=delete
virtual string GetName () const
virtual InsertionOrderPreservingMap< string > ParamsToString () const
virtual string ToString (ExplainFormat format=ExplainFormat::DEFAULT) const
void Print () const
virtual vector< const_reference< PhysicalOperator > > GetChildren () const
const vector< LogicalType > & GetTypes () const
 Return a vector of the types that will be returned by this operator.
virtual bool Equals (const PhysicalOperator &other) const
idx_t EstimatedThreadCount () const
 Functions to help decide how to set up pipeline dependencies.
bool CanSaturateThreads (ClientContext &context) const
virtual void Verify ()
virtual unique_ptr< OperatorState > GetOperatorState (ExecutionContext &context) const
virtual unique_ptr< GlobalOperatorState > GetGlobalOperatorState (ClientContext &context) const
virtual OperatorFinalResultType OperatorFinalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorFinalizeInput &input) const
virtual bool ParallelOperator () const
virtual bool RequiresOperatorFinalize () const
virtual unique_ptr< LocalSourceState > GetLocalSourceState (ExecutionContext &context, GlobalSourceState &gstate) const
virtual unique_ptr< GlobalSourceState > GetGlobalSourceState (ClientContext &context) const
SourceResultType GetData (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const
virtual OperatorPartitionData GetPartitionData (ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate, LocalSourceState &lstate, const OperatorPartitionInfo &partition_info) const
virtual bool IsSource () const
virtual bool ParallelSource () const
virtual bool SupportsPartitioning (const OperatorPartitionInfo &partition_info) const
virtual ProgressData GetProgress (ClientContext &context, GlobalSourceState &gstate) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual ProgressData GetSinkProgress (ClientContext &context, GlobalSinkState &gstate, const ProgressData source_progress) const
 Returns the current progress percentage, or a negative value if progress bars are not supported.
virtual InsertionOrderPreservingMap< string > ExtraSourceParams (GlobalSourceState &gstate, LocalSourceState &lstate) const
virtual SinkResultType Sink (ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const
virtual SinkCombineResultType Combine (ExecutionContext &context, OperatorSinkCombineInput &input) const
virtual void PrepareFinalize (ClientContext &context, GlobalSinkState &sink_state) const
virtual SinkFinalizeType Finalize (Pipeline &pipeline, Event &event, ClientContext &context, OperatorSinkFinalizeInput &input) const
virtual SinkNextBatchType NextBatch (ExecutionContext &context, OperatorSinkNextBatchInput &input) const
virtual unique_ptr< LocalSinkState > GetLocalSinkState (ExecutionContext &context) const
virtual unique_ptr< GlobalSinkState > GetGlobalSinkState (ClientContext &context) const
virtual bool IsSink () const
virtual bool ParallelSink () const
virtual OperatorPartitionInfo RequiredPartitionInfo () const
bool AllSourcesSupportBatchIndex () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static bool HasNullValues (DataChunk &chunk)
static void ConstructSemiJoinResult (DataChunk &left, DataChunk &result, bool found_match[])
static void ConstructAntiJoinResult (DataChunk &left, DataChunk &result, bool found_match[])
static void ConstructMarkJoinResult (DataChunk &join_keys, DataChunk &left, DataChunk &result, bool found_match[], bool has_null)
static void BuildJoinPipelines (Pipeline &current, MetaPipeline &meta_pipeline, PhysicalOperator &op, bool build_rhs=true)
Static Public Member Functions inherited from duckdb::PhysicalOperator
static void SetEstimatedCardinality (InsertionOrderPreservingMap< string > &result, idx_t estimated_cardinality)
static idx_t GetMaxThreadMemory (ClientContext &context)
 The maximum amount of memory the operator should use per thread.
static OperatorCachingMode SelectOperatorCachingMode (ExecutionContext &context)
 Whether operator caching is allowed in the current execution context.

Public Attributes

JoinType join_type
Public Attributes inherited from duckdb::CachingPhysicalOperator
bool caching_supported
Public Attributes inherited from duckdb::PhysicalOperator
ArenaLinkedList< reference< PhysicalOperator > > children
 The child operators.
PhysicalOperatorType type
 The physical operator type.
vector< LogicalType > types
 The return types.
idx_t estimated_cardinality
 The estimated cardinality.
unique_ptr< GlobalSinkState > sink_state
 The global sink state.
unique_ptr< GlobalOperatorState > op_state
 The global operator state.
mutex lock
 Lock for (re)setting any of the operator states.

Static Public Attributes

static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID
Static Public Attributes inherited from duckdb::CachingPhysicalOperator
static constexpr const idx_t CACHE_THRESHOLD = 64
Static Public Attributes inherited from duckdb::PhysicalOperator
static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::INVALID

Additional Inherited Members

Protected Member Functions inherited from duckdb::CachingPhysicalOperator
virtual OperatorResultType ExecuteInternal (ExecutionContext &context, DataChunk &input, DataChunk &chunk, GlobalOperatorState &gstate, OperatorState &state) const =0
 Child classes need to implement the ExecuteInternal method instead of the Execute.
Protected Member Functions inherited from duckdb::PhysicalOperator
virtual SourceResultType GetDataInternal (ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const

Detailed Description

PhysicalJoin represents the base class of the join operators.

Constructor & Destructor Documentation

◆ PhysicalJoin()

duckdb::PhysicalJoin::PhysicalJoin ( PhysicalPlan & physical_plan,
LogicalOperator & op,
PhysicalOperatorType type,
JoinType join_type,
idx_t estimated_cardinality )
187723 : CachingPhysicalOperator(physical_plan, type, op.types, estimated_cardinality), join_type(join_type) {
187724}
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154
PhysicalOperatorType type
The physical operator type.
Definition duckdb.hpp:22150

Member Function Documentation

◆ EmptyResultIfRHSIsEmpty()

bool duckdb::PhysicalJoin::EmptyResultIfRHSIsEmpty ( ) const
187726 {
187727 // empty RHS with INNER, RIGHT or SEMI join means empty result set
187728 switch (join_type) {
187729 case JoinType::INNER:
187730 case JoinType::RIGHT:
187731 case JoinType::SEMI:
187732 case JoinType::RIGHT_SEMI:
187733 case JoinType::RIGHT_ANTI:
187734 return true;
187735 default:
187736 return false;
187737 }
187738}

◆ HasNullValues()

bool duckdb::PhysicalJoin::HasNullValues ( DataChunk & chunk)
static
188168 {
188169 for (idx_t col_idx = 0; col_idx < chunk.ColumnCount(); col_idx++) {
188170 UnifiedVectorFormat vdata;
188171 chunk.data[col_idx].ToUnifiedFormat(chunk.size(), vdata);
188172
188173 if (vdata.validity.AllValid()) {
188174 continue;
188175 }
188176 for (idx_t i = 0; i < chunk.size(); i++) {
188177 auto idx = vdata.sel->get_index(i);
188178 if (!vdata.validity.RowIsValid(idx)) {
188179 return true;
188180 }
188181 }
188182 }
188183 return false;
188184}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ ConstructSemiJoinResult()

void duckdb::PhysicalJoin::ConstructSemiJoinResult ( DataChunk & left,
DataChunk & result,
bool found_match[] )
static
188208 {
188209 ConstructSemiOrAntiJoinResult<true>(left, result, found_match);
188210}

◆ ConstructAntiJoinResult()

void duckdb::PhysicalJoin::ConstructAntiJoinResult ( DataChunk & left,
DataChunk & result,
bool found_match[] )
static
188212 {
188213 ConstructSemiOrAntiJoinResult<false>(left, result, found_match);
188214}

◆ ConstructMarkJoinResult()

void duckdb::PhysicalJoin::ConstructMarkJoinResult ( DataChunk & join_keys,
DataChunk & left,
DataChunk & result,
bool found_match[],
bool has_null )
static
188217 {
188218 // for the initial set of columns we just reference the left side
188219 result.SetCardinality(left);
188220 for (idx_t i = 0; i < left.ColumnCount(); i++) {
188221 result.data[i].Reference(left.data[i]);
188222 }
188223 auto &mark_vector = result.data.back();
188224 mark_vector.SetVectorType(VectorType::FLAT_VECTOR);
188225 // first we set the NULL values from the join keys
188226 // if there is any NULL in the keys, the result is NULL
188227 auto bool_result = FlatVector::GetData<bool>(mark_vector);
188228 auto &mask = FlatVector::Validity(mark_vector);
188229 for (idx_t col_idx = 0; col_idx < join_keys.ColumnCount(); col_idx++) {
188230 UnifiedVectorFormat jdata;
188231 join_keys.data[col_idx].ToUnifiedFormat(join_keys.size(), jdata);
188232 if (!jdata.validity.AllValid()) {
188233 for (idx_t i = 0; i < join_keys.size(); i++) {
188234 auto jidx = jdata.sel->get_index(i);
188235 mask.Set(i, jdata.validity.RowIsValid(jidx));
188236 }
188237 }
188238 }
188239 // now set the remaining entries to either true or false based on whether a match was found
188240 if (found_match) {
188241 for (idx_t i = 0; i < left.size(); i++) {
188242 bool_result[i] = found_match[i];
188243 }
188244 } else {
188245 memset(bool_result, 0, sizeof(bool) * left.size());
188246 }
188247 // if the right side contains NULL values, the result of any FALSE becomes NULL
188248 if (has_null) {
188249 for (idx_t i = 0; i < left.size(); i++) {
188250 if (!bool_result[i]) {
188251 mask.SetInvalid(i);
188252 }
188253 }
188254 }
188255}
GMat mask(const GMat &src, const GMat &mask)

◆ BuildJoinPipelines()

void duckdb::PhysicalJoin::BuildJoinPipelines ( Pipeline & current,
MetaPipeline & meta_pipeline,
PhysicalOperator & op,
bool build_rhs = true )
static
187744 {
187745 op.op_state.reset();
187746 op.sink_state.reset();
187747
187748 // 'current' is the probe pipeline: add this operator
187749 auto &state = meta_pipeline.GetState();
187750 state.AddPipelineOperator(current, op);
187751
187752 // save the last added pipeline to set up dependencies later (in case we need to add a child pipeline)
187753 vector<shared_ptr<Pipeline>> pipelines_so_far;
187754 meta_pipeline.GetPipelines(pipelines_so_far, false);
187755 auto &last_pipeline = *pipelines_so_far.back();
187756
187757 vector<shared_ptr<Pipeline>> dependencies;
187758 optional_ptr<MetaPipeline> last_child_ptr;
187759 if (build_rhs) {
187760 // on the RHS (build side), we construct a child MetaPipeline with this operator as its sink
187761 auto &child_meta_pipeline = meta_pipeline.CreateChildMetaPipeline(current, op, MetaPipelineType::JOIN_BUILD);
187762 child_meta_pipeline.Build(op.children[1]);
187763 if (op.children[1].get().CanSaturateThreads(current.GetClientContext())) {
187764 // if the build side can saturate all available threads,
187765 // we don't just make the LHS pipeline depend on the RHS, but recursively all LHS children too.
187766 // this prevents breadth-first plan evaluation
187767 child_meta_pipeline.GetPipelines(dependencies, false);
187768 last_child_ptr = meta_pipeline.GetLastChild();
187769 }
187770 }
187771
187772 // continue building the current pipeline on the LHS (probe side)
187773 op.children[0].get().BuildPipelines(current, meta_pipeline);
187774
187775 if (last_child_ptr) {
187776 // the pointer was set, set up the dependencies
187777 meta_pipeline.AddRecursiveDependencies(dependencies, *last_child_ptr);
187778 }
187779
187780 switch (op.type) {
187781 case PhysicalOperatorType::POSITIONAL_JOIN:
187782 // Positional joins are always outer
187783 meta_pipeline.CreateChildPipeline(current, op, last_pipeline);
187784 return;
187785 case PhysicalOperatorType::CROSS_PRODUCT:
187786 return;
187787 default:
187788 break;
187789 }
187790
187791 // Join can become a source operator if it's RIGHT/OUTER, or if the hash join goes out-of-core
187792 if (op.Cast<PhysicalJoin>().IsSource()) {
187793 meta_pipeline.CreateChildPipeline(current, op, last_pipeline);
187794 }
187795}
@ JOIN_BUILD
The shared sink is regular.
Definition duckdb.cpp:60634

◆ BuildPipelines()

void duckdb::PhysicalJoin::BuildPipelines ( Pipeline & current,
MetaPipeline & meta_pipeline )
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

187797 {
187798 PhysicalJoin::BuildJoinPipelines(current, meta_pipeline, *this);
187799}

◆ GetSources()

vector< const_reference< PhysicalOperator > > duckdb::PhysicalJoin::GetSources ( ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

187801 {
187802 auto result = children[0].get().GetSources();
187803 if (IsSource()) {
187804 result.push_back(*this);
187805 }
187806 return result;
187807}
ArenaLinkedList< reference< PhysicalOperator > > children
The child operators.
Definition duckdb.hpp:22148

◆ SourceOrder()

OrderPreservationType duckdb::PhysicalJoin::SourceOrder ( ) const
inlineoverridevirtual

The type of order emitted by the operator (as a source).

Reimplemented from duckdb::PhysicalOperator.

180796 {
180797 return OrderPreservationType::NO_ORDER;
180798 }

◆ OperatorOrder()

OrderPreservationType duckdb::PhysicalJoin::OperatorOrder ( ) const
inlineoverridevirtual

The influence the operator has on order (insertion order means no influence).

Reimplemented from duckdb::PhysicalOperator.

180799 {
180800 return OrderPreservationType::NO_ORDER;
180801 }

◆ SinkOrderDependent()

bool duckdb::PhysicalJoin::SinkOrderDependent ( ) const
inlineoverridevirtual

Whether or not the sink operator depends on the order of the input chunks If this is set to true, we cannot do things like caching intermediate vectors

Reimplemented from duckdb::PhysicalOperator.

180802 {
180803 return false;
180804 }

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