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

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

Inheritance diagram for duckdb::PhysicalComparisonJoin:
Collaboration diagram for duckdb::PhysicalComparisonJoin:

Public Member Functions

 PhysicalComparisonJoin (PhysicalPlan &physical_plan, LogicalOperator &op, PhysicalOperatorType type, vector< JoinCondition > cond, JoinType join_type, idx_t estimated_cardinality)
InsertionOrderPreservingMap< string > ParamsToString () const override
Public Member Functions inherited from duckdb::PhysicalJoin
 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 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 void ReorderConditions (vector< JoinCondition > &conditions)
 Re-order join conditions so that equality predicates are first, followed by other predicates.
static void ConstructEmptyJoinResult (JoinType type, bool has_null, DataChunk &input, DataChunk &result)
 Construct the join result of a join with an empty RHS.
static void ConstructFullOuterJoinResult (bool *found_match, ColumnDataCollection &input, DataChunk &result, ColumnDataScanState &scan_state)
 Construct the remainder of a Full Outer Join based on which tuples in the RHS found no match.
Static Public Member Functions inherited from duckdb::PhysicalJoin
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

vector< JoinCondition > conditions
unique_ptr< JoinFilterPushdownInfo > filter_pushdown
 Scans where we should push generated filters into (if any).
Public Attributes inherited from duckdb::PhysicalJoin
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.

Additional Inherited Members

Static Public Attributes inherited from duckdb::PhysicalJoin
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
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

◆ PhysicalComparisonJoin()

duckdb::PhysicalComparisonJoin::PhysicalComparisonJoin ( PhysicalPlan & physical_plan,
LogicalOperator & op,
PhysicalOperatorType type,
vector< JoinCondition > cond,
JoinType join_type,
idx_t estimated_cardinality )
183793 : PhysicalJoin(physical_plan, op, type, join_type, estimated_cardinality), conditions(std::move(conditions_p)) {
183794 ReorderConditions(conditions);
183795}
static void ReorderConditions(vector< JoinCondition > &conditions)
Re-order join conditions so that equality predicates are first, followed by other predicates.
Definition duckdb.cpp:183817
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154
PhysicalOperatorType type
The physical operator type.
Definition duckdb.hpp:22150

Member Function Documentation

◆ ParamsToString()

InsertionOrderPreservingMap< string > duckdb::PhysicalComparisonJoin::ParamsToString ( ) const
overridevirtual

Reimplemented from duckdb::PhysicalOperator.

183797 {
183798 InsertionOrderPreservingMap<string> result;
183799 result["Join Type"] = EnumUtil::ToString(join_type);
183800 string condition_info;
183801 for (idx_t i = 0; i < conditions.size(); i++) {
183802 auto &join_condition = conditions[i];
183803 if (i > 0) {
183804 condition_info += "\n";
183805 }
183806 condition_info +=
183807 StringUtil::Format("%s %s %s", join_condition.left->GetName(),
183808 ExpressionTypeToOperator(join_condition.comparison), join_condition.right->GetName());
183809 // string op = ExpressionTypeToOperator(it.comparison);
183810 // extra_info += it.left->GetName() + " " + op + " " + it.right->GetName() + "\n";
183811 }
183812 result["Conditions"] = condition_info;
183813 SetEstimatedCardinality(result, estimated_cardinality);
183814 return result;
183815}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ ReorderConditions()

void duckdb::PhysicalComparisonJoin::ReorderConditions ( vector< JoinCondition > & conditions)
static

Re-order join conditions so that equality predicates are first, followed by other predicates.

183817 {
183818 // we reorder conditions so the ones with COMPARE_EQUAL occur first
183819 // check if this is already the case
183820 bool is_ordered = true;
183821 bool seen_non_equal = false;
183822 for (auto &cond : conditions) {
183823 if (cond.comparison == ExpressionType::COMPARE_EQUAL ||
183824 cond.comparison == ExpressionType::COMPARE_NOT_DISTINCT_FROM) {
183825 if (seen_non_equal) {
183826 is_ordered = false;
183827 break;
183828 }
183829 } else {
183830 seen_non_equal = true;
183831 }
183832 }
183833 if (is_ordered) {
183834 // no need to re-order
183835 return;
183836 }
183837 // gather lists of equal/other conditions
183838 vector<JoinCondition> equal_conditions;
183839 vector<JoinCondition> other_conditions;
183840 for (auto &cond : conditions) {
183841 if (cond.comparison == ExpressionType::COMPARE_EQUAL ||
183842 cond.comparison == ExpressionType::COMPARE_NOT_DISTINCT_FROM) {
183843 equal_conditions.push_back(std::move(cond));
183844 } else {
183845 other_conditions.push_back(std::move(cond));
183846 }
183847 }
183848 conditions.clear();
183849 // reconstruct the sorted conditions
183850 for (auto &cond : equal_conditions) {
183851 conditions.push_back(std::move(cond));
183852 }
183853 for (auto &cond : other_conditions) {
183854 conditions.push_back(std::move(cond));
183855 }
183856}

◆ ConstructEmptyJoinResult()

void duckdb::PhysicalComparisonJoin::ConstructEmptyJoinResult ( JoinType type,
bool has_null,
DataChunk & input,
DataChunk & result )
static

Construct the join result of a join with an empty RHS.

183859 {
183860 // empty hash table, special case
183861 if (join_type == JoinType::ANTI) {
183862 // anti join with empty hash table, NOP join
183863 // return the input
183864 D_ASSERT(input.ColumnCount() == result.ColumnCount());
183865 result.Reference(input);
183866 } else if (join_type == JoinType::MARK) {
183867 // MARK join with empty hash table
183868 D_ASSERT(result.ColumnCount() == input.ColumnCount() + 1);
183869 auto &result_vector = result.data.back();
183870 D_ASSERT(result_vector.GetType() == LogicalType::BOOLEAN);
183871 // for every data vector, we just reference the child chunk
183872 result.SetCardinality(input);
183873 for (idx_t i = 0; i < input.ColumnCount(); i++) {
183874 result.data[i].Reference(input.data[i]);
183875 }
183876 // for the MARK vector:
183877 // if the HT has no NULL values (i.e. empty result set), return a vector that has false for every input
183878 // entry if the HT has NULL values (i.e. result set had values, but all were NULL), return a vector that
183879 // has NULL for every input entry
183880 if (!has_null) {
183881 auto bool_result = FlatVector::GetData<bool>(result_vector);
183882 for (idx_t i = 0; i < result.size(); i++) {
183883 bool_result[i] = false;
183884 }
183885 } else {
183886 FlatVector::Validity(result_vector).SetAllInvalid(result.size());
183887 }
183888 } else if (join_type == JoinType::LEFT || join_type == JoinType::OUTER || join_type == JoinType::SINGLE) {
183889 // LEFT/FULL OUTER/SINGLE join and build side is empty
183890 // for the LHS we reference the data
183891 result.SetCardinality(input.size());
183892 for (idx_t i = 0; i < input.ColumnCount(); i++) {
183893 result.data[i].Reference(input.data[i]);
183894 }
183895 // for the RHS
183896 for (idx_t k = input.ColumnCount(); k < result.ColumnCount(); k++) {
183897 result.data[k].SetVectorType(VectorType::CONSTANT_VECTOR);
183898 ConstantVector::SetNull(result.data[k], true);
183899 }
183900 }
183901}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445
Here is the caller graph for this function:

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