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::PhysicalRangeJoin Class Reference
Inheritance diagram for duckdb::PhysicalRangeJoin:
Collaboration diagram for duckdb::PhysicalRangeJoin:

Classes

class  LocalSortedTable
class  GlobalSortedTable

Public Types

using ProjectionMapping = vector<column_t>

Public Member Functions

 PhysicalRangeJoin (PhysicalPlan &physical_plan, LogicalComparisonJoin &op, PhysicalOperatorType type, PhysicalOperator &left, PhysicalOperator &right, vector< JoinCondition > cond, JoinType join_type, idx_t estimated_cardinality, unique_ptr< JoinFilterPushdownInfo > pushdown_info)
void ProjectResult (DataChunk &chunk, DataChunk &result) const
 Utility to project full width internal chunks to projected results.
Public Member Functions inherited from duckdb::PhysicalComparisonJoin
 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 SliceSortedPayload (DataChunk &chunk, GlobalSortedTable &table, ExternalBlockIteratorState &state, TupleDataChunkState &chunk_state, const idx_t chunk_idx, const unsafe_vector< idx_t > &result, SortedRunScanState &scan_state)
static idx_t SelectJoinTail (const ExpressionType &condition, Vector &left, Vector &right, const SelectionVector *sel, idx_t count, SelectionVector *true_sel)
Static Public Member Functions inherited from duckdb::PhysicalComparisonJoin
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

ProjectionMapping left_projection_map
ProjectionMapping right_projection_map
vector< LogicalType > unprojected_types
 The full set of types (left + right child).
Public Attributes inherited from duckdb::PhysicalComparisonJoin
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

PhysicalRangeJoin represents one or more inequality range join predicates between two tables

Constructor & Destructor Documentation

◆ PhysicalRangeJoin()

duckdb::PhysicalRangeJoin::PhysicalRangeJoin ( PhysicalPlan & physical_plan,
LogicalComparisonJoin & op,
PhysicalOperatorType type,
PhysicalOperator & left,
PhysicalOperator & right,
vector< JoinCondition > cond,
JoinType join_type,
idx_t estimated_cardinality,
unique_ptr< JoinFilterPushdownInfo > pushdown_info )
190061 : PhysicalComparisonJoin(physical_plan, op, type, std::move(cond), join_type, estimated_cardinality) {
190062 filter_pushdown = std::move(pushdown_info);
190063 // Reorder the conditions so that ranges are at the front.
190064 // TODO: use stats to improve the choice?
190065 // TODO: Prefer fixed length types?
190066 if (conditions.size() > 1) {
190067 unordered_map<idx_t, idx_t> cond_idx;
190068 vector<JoinCondition> conditions_p(conditions.size());
190069 std::swap(conditions_p, conditions);
190070 idx_t range_position = 0;
190071 idx_t other_position = conditions_p.size();
190072 for (idx_t i = 0; i < conditions_p.size(); ++i) {
190073 switch (conditions_p[i].comparison) {
190074 case ExpressionType::COMPARE_LESSTHAN:
190075 case ExpressionType::COMPARE_LESSTHANOREQUALTO:
190076 case ExpressionType::COMPARE_GREATERTHAN:
190077 case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
190078 conditions[range_position++] = std::move(conditions_p[i]);
190079 cond_idx[i] = range_position - 1;
190080 break;
190081 default:
190082 conditions[--other_position] = std::move(conditions_p[i]);
190083 cond_idx[i] = other_position;
190084 break;
190085 }
190086 }
190087 if (filter_pushdown) {
190088 for (auto &idx : filter_pushdown->join_condition) {
190089 if (cond_idx.find(idx) != cond_idx.end()) {
190090 idx = cond_idx[idx];
190091 }
190092 }
190093 }
190094 }
190095
190096 children.push_back(left);
190097 children.push_back(right);
190098
190099 // Fill out the left projection map.
190100 left_projection_map = op.left_projection_map;
190101 if (left_projection_map.empty()) {
190102 const auto left_count = children[0].get().GetTypes().size();
190103 left_projection_map.reserve(left_count);
190104 for (column_t i = 0; i < left_count; ++i) {
190105 left_projection_map.emplace_back(i);
190106 }
190107 }
190108 // Fill out the right projection map.
190109 right_projection_map = op.right_projection_map;
190110 if (right_projection_map.empty()) {
190111 const auto right_count = children[1].get().GetTypes().size();
190112 right_projection_map.reserve(right_count);
190113 for (column_t i = 0; i < right_count; ++i) {
190114 right_projection_map.emplace_back(i);
190115 }
190116 }
190117
190118 // Construct the unprojected type layout from the children's types
190119 unprojected_types = children[0].get().GetTypes();
190120 auto &types = children[1].get().GetTypes();
190121 unprojected_types.insert(unprojected_types.end(), types.begin(), types.end());
190122}
unique_ptr< JoinFilterPushdownInfo > filter_pushdown
Scans where we should push generated filters into (if any).
Definition duckdb.cpp:180824
vector< LogicalType > types
The return types.
Definition duckdb.hpp:22152
idx_t estimated_cardinality
The estimated cardinality.
Definition duckdb.hpp:22154
PhysicalOperatorType type
The physical operator type.
Definition duckdb.hpp:22150
ArenaLinkedList< reference< PhysicalOperator > > children
The child operators.
Definition duckdb.hpp:22148
vector< LogicalType > unprojected_types
The full set of types (left + right child).
Definition duckdb.cpp:185996
idx_t column_t
Type used for column identifiers.
Definition duckdb.hpp:259
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

Member Function Documentation

◆ SliceSortedPayload()

void duckdb::PhysicalRangeJoin::SliceSortedPayload ( DataChunk & chunk,
GlobalSortedTable & table,
ExternalBlockIteratorState & state,
TupleDataChunkState & chunk_state,
const idx_t chunk_idx,
const unsafe_vector< idx_t > & result,
SortedRunScanState & scan_state )
static
190251 {
190252 auto &sorted = *table.sorted;
190253 auto &sort_keys = chunk_state.row_locations;
190254 const auto sort_key_type = table.GetSortKeyType();
190255
190256 switch (sort_key_type) {
190258 TemplatedSliceSortedPayload<SortKeyType::NO_PAYLOAD_FIXED_8>(chunk, sorted, state, sort_keys, scan_state,
190259 chunk_idx, result);
190260 break;
190261 case SortKeyType::NO_PAYLOAD_FIXED_16:
190262 TemplatedSliceSortedPayload<SortKeyType::NO_PAYLOAD_FIXED_16>(chunk, sorted, state, sort_keys, scan_state,
190263 chunk_idx, result);
190264 break;
190265 case SortKeyType::NO_PAYLOAD_FIXED_24:
190266 TemplatedSliceSortedPayload<SortKeyType::NO_PAYLOAD_FIXED_24>(chunk, sorted, state, sort_keys, scan_state,
190267 chunk_idx, result);
190268 break;
190269 case SortKeyType::NO_PAYLOAD_FIXED_32:
190270 TemplatedSliceSortedPayload<SortKeyType::NO_PAYLOAD_FIXED_32>(chunk, sorted, state, sort_keys, scan_state,
190271 chunk_idx, result);
190272 break;
190273 case SortKeyType::NO_PAYLOAD_VARIABLE_32:
190274 TemplatedSliceSortedPayload<SortKeyType::NO_PAYLOAD_VARIABLE_32>(chunk, sorted, state, sort_keys, scan_state,
190275 chunk_idx, result);
190276 break;
190278 TemplatedSliceSortedPayload<SortKeyType::PAYLOAD_FIXED_16>(chunk, sorted, state, sort_keys, scan_state,
190279 chunk_idx, result);
190280 break;
190281 case SortKeyType::PAYLOAD_FIXED_24:
190282 TemplatedSliceSortedPayload<SortKeyType::PAYLOAD_FIXED_24>(chunk, sorted, state, sort_keys, scan_state,
190283 chunk_idx, result);
190284 break;
190285 case SortKeyType::PAYLOAD_FIXED_32:
190286 TemplatedSliceSortedPayload<SortKeyType::PAYLOAD_FIXED_32>(chunk, sorted, state, sort_keys, scan_state,
190287 chunk_idx, result);
190288 break;
190289 case SortKeyType::PAYLOAD_VARIABLE_32:
190290 TemplatedSliceSortedPayload<SortKeyType::PAYLOAD_VARIABLE_32>(chunk, sorted, state, sort_keys, scan_state,
190291 chunk_idx, result);
190292 break;
190293 default:
190294 throw NotImplementedException("MergeJoinSimpleBlocks for %s", EnumUtil::ToString(sort_key_type));
190295 }
190296}
@ NO_PAYLOAD_FIXED_8
Without payload.
Definition duckdb.cpp:55338
@ PAYLOAD_FIXED_16
With payload (requires row pointer in key).
Definition duckdb.cpp:55344

◆ SelectJoinTail()

idx_t duckdb::PhysicalRangeJoin::SelectJoinTail ( const ExpressionType & condition,
Vector & left,
Vector & right,
const SelectionVector * sel,
idx_t count,
SelectionVector * true_sel )
static
190299 {
190300 switch (condition) {
190301 case ExpressionType::COMPARE_NOTEQUAL:
190302 return VectorOperations::NotEquals(left, right, sel, count, true_sel, nullptr);
190303 case ExpressionType::COMPARE_LESSTHAN:
190304 return VectorOperations::LessThan(left, right, sel, count, true_sel, nullptr);
190305 case ExpressionType::COMPARE_GREATERTHAN:
190306 return VectorOperations::GreaterThan(left, right, sel, count, true_sel, nullptr);
190307 case ExpressionType::COMPARE_LESSTHANOREQUALTO:
190308 return VectorOperations::LessThanEquals(left, right, sel, count, true_sel, nullptr);
190309 case ExpressionType::COMPARE_GREATERTHANOREQUALTO:
190310 return VectorOperations::GreaterThanEquals(left, right, sel, count, true_sel, nullptr);
190311 case ExpressionType::COMPARE_DISTINCT_FROM:
190312 return VectorOperations::DistinctFrom(left, right, sel, count, true_sel, nullptr);
190313 case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
190314 return VectorOperations::NotDistinctFrom(left, right, sel, count, true_sel, nullptr);
190315 case ExpressionType::COMPARE_EQUAL:
190316 return VectorOperations::Equals(left, right, sel, count, true_sel, nullptr);
190317 default:
190318 throw InternalException("Unsupported comparison type for PhysicalRangeJoin");
190319 }
190320
190321 return count;
190322}

◆ ProjectResult()

void duckdb::PhysicalRangeJoin::ProjectResult ( DataChunk & chunk,
DataChunk & result ) const

Utility to project full width internal chunks to projected results.

190216 {
190217 const auto left_projected = left_projection_map.size();
190218 for (idx_t i = 0; i < left_projected; ++i) {
190219 result.data[i].Reference(chunk.data[left_projection_map[i]]);
190220 }
190221 const auto left_width = children[0].get().GetTypes().size();
190222 for (idx_t i = 0; i < right_projection_map.size(); ++i) {
190223 result.data[left_projected + i].Reference(chunk.data[left_width + right_projection_map[i]]);
190224 }
190225 result.SetCardinality(chunk);
190226}
vector< Vector > data
The vectors owned by the DataChunk.
Definition duckdb.hpp:11445

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