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

Public Types

using HashGroupPtr = unique_ptr<SortedRun>
using ChunkRow = SortStrategy::ChunkRow

Public Member Functions

 AsOfHashGroup (const PhysicalAsOfJoin &op, const ChunkRow &left_stats, const ChunkRow &right_stats, const idx_t hash_group)
bool IsRightOuter () const
 Is this a right join (do we have a RIGHT stage?).
AsOfJoinSourceStage GetStage () const
 The processing stage for this group.
idx_t GetTaskCount () const
 The total number of tasks we will execute.
idx_t LeftChunks () const
 The number of left chunks.
idx_t RightChunks () const
 The number of right chunks.
idx_t InitTasks (idx_t per_thread)
idx_t MaximumChunks () const
 The maximum number of chunks that we will scan for each state.
bool TryPrepareNextStage ()
 Try to move to the next stage.
bool TryNextTask (AsOfSourceTask &task)
 Try to get another task for this group.
bool FinishTask (AsOfSourceTask &task)
 Finish the given task. Returns true if there are no more tasks.

Static Public Member Functions

template<typename T>
static T BinValue (T n, T val)

Public Attributes

const PhysicalAsOfJoin & op
 The parent operator.
const idx_t group_idx
 The group number.
const ChunkRow left_stats
 The number of left chunks/rows.
const ChunkRow right_stats
 The number of right chunks/rows.
HashGroupPtr left_group
 The left hash partition data.
HashGroupPtr right_group
 The right hash partition data.
OuterJoinMarker right_outer
 The right outer join markers.
AsOfJoinSourceStage stage
idx_t per_thread = 0
 The the number of blocks per thread.
vector< idx_t > stage_tasks
 The the number of tasks per stage.
vector< idx_t > stage_begin
 The the first task in the stage.
idx_t next_task = 0
 The next task to process.
std::atomic< idx_t > sorted
 Count of sorting tasks completed.
std::atomic< idx_t > materialized
 Count of materialization tasks completed.
std::atomic< idx_t > gotten
 Count of get tasks completed.
std::atomic< idx_t > left_completed
 Count of left side tasks completed.
std::atomic< idx_t > right_completed
 Count of right side tasks completed.

Constructor & Destructor Documentation

◆ AsOfHashGroup()

duckdb::AsOfHashGroup::AsOfHashGroup ( const PhysicalAsOfJoin & op,
const ChunkRow & left_stats,
const ChunkRow & right_stats,
const idx_t hash_group )
182067 right_outer(IsRightOuterJoin(op.join_type)), stage(AsOfJoinSourceStage::INIT), sorted(0), materialized(0),
182069 right_outer.Initialize(right_stats.count);
182070}
std::atomic< idx_t > sorted
Count of sorting tasks completed.
Definition duckdb.cpp:182053
const idx_t group_idx
The group number.
Definition duckdb.cpp:182031
OuterJoinMarker right_outer
The right outer join markers.
Definition duckdb.cpp:182041
std::atomic< idx_t > gotten
Count of get tasks completed.
Definition duckdb.cpp:182057
const ChunkRow left_stats
The number of left chunks/rows.
Definition duckdb.cpp:182033
std::atomic< idx_t > materialized
Count of materialization tasks completed.
Definition duckdb.cpp:182055
std::atomic< idx_t > left_completed
Count of left side tasks completed.
Definition duckdb.cpp:182059
const ChunkRow right_stats
The number of right chunks/rows.
Definition duckdb.cpp:182035
const PhysicalAsOfJoin & op
The parent operator.
Definition duckdb.cpp:182029
std::atomic< idx_t > right_completed
Count of right side tasks completed.
Definition duckdb.cpp:182061
bool IsRightOuterJoin(JoinType type)
True if join is rght or full outer join.
Definition duckdb.cpp:68423

Member Function Documentation

◆ BinValue()

template<typename T>
T duckdb::AsOfHashGroup::BinValue ( T n,
T val )
inlinestatic
181981 {
181982 return ((n + (val - 1)) / val);
181983 }

◆ IsRightOuter()

bool duckdb::AsOfHashGroup::IsRightOuter ( ) const
inline

Is this a right join (do we have a RIGHT stage?).

181989 {
181990 return right_outer.Enabled();
181991 }
Here is the caller graph for this function:

◆ GetStage()

AsOfJoinSourceStage duckdb::AsOfHashGroup::GetStage ( ) const
inline

The processing stage for this group.

181994 {
181995 return stage;
181996 }
Here is the caller graph for this function:

◆ GetTaskCount()

idx_t duckdb::AsOfHashGroup::GetTaskCount ( ) const
inline

The total number of tasks we will execute.

181999 {
182000 return stage_begin[size_t(AsOfJoinSourceStage::DONE)];
182001 }
vector< idx_t > stage_begin
The the first task in the stage.
Definition duckdb.cpp:182049
Here is the caller graph for this function:

◆ LeftChunks()

idx_t duckdb::AsOfHashGroup::LeftChunks ( ) const
inline

The number of left chunks.

182004 {
182005 return left_stats.chunks;
182006 }
Here is the caller graph for this function:

◆ RightChunks()

idx_t duckdb::AsOfHashGroup::RightChunks ( ) const
inline

The number of right chunks.

182009 {
182010 return right_stats.chunks;
182011 }
Here is the caller graph for this function:

◆ InitTasks()

idx_t duckdb::AsOfHashGroup::InitTasks ( idx_t per_thread)
182072 {
182073 per_thread = per_thread_p;
182074
182075 // INIT
182076 stage_tasks.emplace_back(0);
182077
182078 // SORT
182079 auto materialize_tasks = BinValue(LeftChunks(), per_thread);
182080 materialize_tasks += BinValue(RightChunks(), per_thread);
182081 stage_tasks.emplace_back(materialize_tasks);
182082
182083 // MATERIALIZE
182084 stage_tasks.emplace_back(materialize_tasks);
182085
182086 // GET
182087 stage_tasks.emplace_back(materialize_tasks ? 1 : 0);
182088
182089 // LEFT
182090 const auto left_tasks = BinValue(LeftChunks(), per_thread);
182091 stage_tasks.emplace_back(left_tasks);
182092
182093 // RIGHT
182094 const auto right_chunks = IsRightOuter() ? RightChunks() : 0;
182095 const auto right_tasks = BinValue(right_chunks, per_thread);
182096 stage_tasks.emplace_back(right_tasks);
182097
182098 // DONE
182099 stage_tasks.emplace_back(0);
182100
182101 // Accumulate task counts so we can find boundaries reliably
182102 idx_t begin = 0;
182103 for (const auto &stage_task : stage_tasks) {
182104 stage_begin.emplace_back(begin);
182105 begin += stage_task;
182106 }
182107
182108 stage = AsOfJoinSourceStage(1);
182109
182110 return GetTaskCount();
182111}
idx_t LeftChunks() const
The number of left chunks.
Definition duckdb.cpp:182004
bool IsRightOuter() const
Is this a right join (do we have a RIGHT stage?).
Definition duckdb.cpp:181989
vector< idx_t > stage_tasks
The the number of tasks per stage.
Definition duckdb.cpp:182047
idx_t per_thread
The the number of blocks per thread.
Definition duckdb.cpp:182045
idx_t GetTaskCount() const
The total number of tasks we will execute.
Definition duckdb.cpp:181999
idx_t RightChunks() const
The number of right chunks.
Definition duckdb.cpp:182009
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ MaximumChunks()

idx_t duckdb::AsOfHashGroup::MaximumChunks ( ) const
inline

The maximum number of chunks that we will scan for each state.

182017 {
182018 return MaxValue(LeftChunks(), RightChunks());
182019 }
Here is the call graph for this function:

◆ TryPrepareNextStage()

bool duckdb::AsOfHashGroup::TryPrepareNextStage ( )

Try to move to the next stage.

182113 {
182114 switch (stage) {
182115 case AsOfJoinSourceStage::INIT:
182116 stage = AsOfJoinSourceStage::SORT;
182117 return true;
182118 case AsOfJoinSourceStage::SORT:
182119 if (sorted >= stage_tasks[size_t(stage)]) {
182120 stage = AsOfJoinSourceStage::MATERIALIZE;
182121 return true;
182122 }
182123 break;
182124 case AsOfJoinSourceStage::MATERIALIZE:
182125 if (materialized >= stage_tasks[size_t(stage)]) {
182126 stage = AsOfJoinSourceStage::GET;
182127 return true;
182128 }
182129 break;
182130 case AsOfJoinSourceStage::GET:
182131 if (gotten >= stage_tasks[size_t(stage)]) {
182132 stage = AsOfJoinSourceStage::LEFT;
182133 return true;
182134 }
182135 break;
182136 case AsOfJoinSourceStage::LEFT:
182137 if (left_completed >= stage_tasks[size_t(stage)]) {
182138 stage = stage_tasks[size_t(AsOfJoinSourceStage::RIGHT)] ? AsOfJoinSourceStage::RIGHT
182139 : AsOfJoinSourceStage::DONE;
182140 return true;
182141 }
182142 break;
182143 case AsOfJoinSourceStage::RIGHT:
182144 if (right_completed >= stage_tasks[size_t(stage)]) {
182145 stage = AsOfJoinSourceStage::DONE;
182146 return true;
182147 }
182148 break;
182149 case AsOfJoinSourceStage::DONE:
182150 return true;
182151 }
182152
182153 return false;
182154}

◆ TryNextTask()

bool duckdb::AsOfHashGroup::TryNextTask ( AsOfSourceTask & task)

Try to get another task for this group.

182156 {
182157 if (next_task >= GetTaskCount()) {
182158 return false;
182159 }
182160
182161 // Search for where we are in the task list
182162 for (idx_t stage = idx_t(AsOfJoinSourceStage::INIT); stage <= idx_t(AsOfJoinSourceStage::DONE); ++stage) {
182163 if (next_task < stage_begin[stage]) {
182164 task.stage = AsOfJoinSourceStage(stage - 1);
182165 task.thread_idx = next_task - stage_begin[size_t(task.stage)];
182166 break;
182167 }
182168 }
182169
182170 if (task.stage != GetStage()) {
182171 return false;
182172 }
182173
182174 task.group_idx = group_idx;
182175 task.begin_idx = 0;
182176 task.end_idx = 0;
182177
182178 switch (task.stage) {
182179 case AsOfJoinSourceStage::SORT:
182180 task.begin_idx = task.thread_idx * per_thread;
182181 task.max_idx = LeftChunks() + RightChunks();
182182 task.end_idx = MinValue<idx_t>(task.begin_idx + per_thread, task.max_idx);
182183 break;
182184 case AsOfJoinSourceStage::MATERIALIZE:
182185 if (!left_group || !right_group) {
182186 task.begin_idx = task.thread_idx * per_thread;
182187 task.max_idx = LeftChunks() + RightChunks();
182188 task.end_idx = MinValue<idx_t>(task.begin_idx + per_thread, task.max_idx);
182189 }
182190 break;
182191 case AsOfJoinSourceStage::GET:
182192 task.begin_idx = 0;
182193 task.end_idx = 1;
182194 task.max_idx = 1;
182195 break;
182196 case AsOfJoinSourceStage::LEFT:
182197 if (left_group) {
182198 task.begin_idx = task.thread_idx * per_thread;
182199 task.max_idx = LeftChunks();
182200 task.end_idx = MinValue<idx_t>(task.begin_idx + per_thread, task.max_idx);
182201 }
182202 break;
182203 case AsOfJoinSourceStage::RIGHT:
182204 if (right_group) {
182205 task.begin_idx = task.thread_idx * per_thread;
182206 task.max_idx = RightChunks();
182207 task.end_idx = MinValue<idx_t>(task.begin_idx + per_thread, task.max_idx);
182208 }
182209 break;
182210 case AsOfJoinSourceStage::INIT:
182211 case AsOfJoinSourceStage::DONE:
182212 break;
182213 }
182214
182215 ++next_task;
182216
182217 return true;
182218}
HashGroupPtr left_group
The left hash partition data.
Definition duckdb.cpp:182037
AsOfJoinSourceStage GetStage() const
The processing stage for this group.
Definition duckdb.cpp:181994
idx_t next_task
The next task to process.
Definition duckdb.cpp:182051
HashGroupPtr right_group
The right hash partition data.
Definition duckdb.cpp:182039
Here is the call graph for this function:

◆ FinishTask()

bool duckdb::AsOfHashGroup::FinishTask ( AsOfSourceTask & task)

Finish the given task. Returns true if there are no more tasks.

182220 {
182221 // Inside the lock
182222 switch (task.stage) {
182223 case AsOfJoinSourceStage::SORT:
182224 case AsOfJoinSourceStage::MATERIALIZE:
182225 case AsOfJoinSourceStage::GET:
182226 break;
182227 case AsOfJoinSourceStage::LEFT:
182228 if (left_completed >= stage_tasks[size_t(task.stage)]) {
182229 left_group.reset();
182230 if (!IsRightOuter()) {
182231 right_group.reset();
182232 }
182233 }
182234 break;
182235 case AsOfJoinSourceStage::RIGHT:
182236 if (right_completed >= stage_tasks[size_t(task.stage)]) {
182237 right_group.reset();
182238 }
182239 break;
182240 case AsOfJoinSourceStage::INIT:
182241 case AsOfJoinSourceStage::DONE:
182242 break;
182243 }
182244
182246}
Here is the call graph for this function:

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