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

Public Member Functions

 HashJoinRepartitionEvent (Pipeline &pipeline_p, const PhysicalHashJoin &op_p, HashJoinGlobalSinkState &sink, vector< unique_ptr< JoinHashTable > > &local_hts)
void Schedule () override
void FinishEvent () override
 Called right after the event is finished.
Public Member Functions inherited from duckdb::BasePipelineEvent
 BasePipelineEvent (shared_ptr< Pipeline > pipeline)
 BasePipelineEvent (Pipeline &pipeline)
void PrintPipeline () override
Public Member Functions inherited from duckdb::Event
 Event (Executor &executor)
virtual void FinalizeFinish ()
 Called after the event is entirely finished.
void FinishTask ()
void Finish ()
void AddDependency (Event &event)
bool HasDependencies () const
const vector< reference< Event > > & GetParentsVerification () const
void CompleteDependency ()
void SetTasks (vector< shared_ptr< Task > > tasks)
void InsertEvent (shared_ptr< Event > replacement_event)
bool IsFinished () const
ClientContext & GetClientContext ()
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const
Public Member Functions inherited from duckdb::enable_shared_from_this< Event >
shared_ptr< Event > shared_from_this ()

Public Attributes

const PhysicalHashJoin & op
HashJoinGlobalSinkState & sink
vector< unique_ptr< JoinHashTable > > & local_hts
Public Attributes inherited from duckdb::BasePipelineEvent
shared_ptr< Pipeline > pipeline
 The pipeline that this event belongs to.

Additional Inherited Members

Protected Member Functions inherited from duckdb::enable_shared_from_this< Event >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept
Protected Attributes inherited from duckdb::Event
Executor & executor
atomic< idx_t > finished_tasks
 The current threads working on the event.
atomic< idx_t > total_tasks
 The maximum amount of threads that can work on the event.
atomic< idx_t > finished_dependencies
idx_t total_dependencies
 The total amount of dependencies.
vector< weak_ptr< Event > > parents
 The events that depend on this event to run.
vector< reference< Event > > parents_raw
 Raw pointers to the parents (used for verification only).
atomic< bool > finished
 Whether or not the event is finished executing.

Constructor & Destructor Documentation

◆ HashJoinRepartitionEvent()

duckdb::HashJoinRepartitionEvent::HashJoinRepartitionEvent ( Pipeline & pipeline_p,
const PhysicalHashJoin & op_p,
HashJoinGlobalSinkState & sink,
vector< unique_ptr< JoinHashTable > > & local_hts )
inline
184848 : BasePipelineEvent(pipeline_p), op(op_p), sink(sink), local_hts(local_hts) {
184849 }

Member Function Documentation

◆ Schedule()

void duckdb::HashJoinRepartitionEvent::Schedule ( )
inlineoverridevirtual

Implements duckdb::Event.

184856 {
184857 D_ASSERT(sink.hash_table->GetRadixBits() > JoinHashTable::INITIAL_RADIX_BITS);
184858 auto block_size = sink.hash_table->buffer_manager.GetBlockSize();
184859
184860 idx_t total_size = 0;
184861 idx_t total_count = 0;
184862 for (auto &local_ht : local_hts) {
184863 auto &sink_collection = local_ht->GetSinkCollection();
184864 total_size += sink_collection.SizeInBytes();
184865 total_count += sink_collection.Count();
184866 }
184867 auto total_blocks = (total_size + block_size - 1) / block_size;
184868 auto count_per_block = total_count / total_blocks;
184869 auto blocks_per_vector = MaxValue<idx_t>(STANDARD_VECTOR_SIZE / count_per_block, 2);
184870
184871 // Assume 8 blocks per partition per thread (4 input, 4 output)
184872 auto partition_multiplier =
184873 RadixPartitioning::NumberOfPartitions(sink.hash_table->GetRadixBits() - JoinHashTable::INITIAL_RADIX_BITS);
184874 auto thread_memory = 2 * blocks_per_vector * partition_multiplier * block_size;
184875 auto repartition_threads = MaxValue<idx_t>(sink.temporary_memory_state->GetReservation() / thread_memory, 1);
184876
184877 if (repartition_threads < local_hts.size()) {
184878 // Limit the number of threads working on repartitioning based on our memory reservation
184879 for (idx_t thread_idx = repartition_threads; thread_idx < local_hts.size(); thread_idx++) {
184880 local_hts[thread_idx % repartition_threads]->Merge(*local_hts[thread_idx]);
184881 }
184882 local_hts.resize(repartition_threads);
184883 }
184884
184885 auto &context = pipeline->GetClientContext();
184886
184887 vector<shared_ptr<Task>> partition_tasks;
184888 partition_tasks.reserve(local_hts.size());
184889 for (auto &local_ht : local_hts) {
184890 partition_tasks.push_back(
184891 make_uniq<HashJoinRepartitionTask>(shared_from_this(), context, *sink.hash_table, *local_ht, op));
184892 }
184893 SetTasks(std::move(partition_tasks));
184894 }
shared_ptr< Pipeline > pipeline
The pipeline that this event belongs to.
Definition duckdb.cpp:35137
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static constexpr idx_t NumberOfPartitions(idx_t radix_bits)
The number of partitions for a given number of radix bits.
Definition duckdb.cpp:93425

◆ FinishEvent()

void duckdb::HashJoinRepartitionEvent::FinishEvent ( )
inlineoverridevirtual

Called right after the event is finished.

Reimplemented from duckdb::Event.

184896 {
184897 local_hts.clear();
184898
184899 // Minimum reservation is now the new smallest partition size
184900 const auto num_partitions = RadixPartitioning::NumberOfPartitions(sink.hash_table->GetRadixBits());
184901 vector<idx_t> partition_sizes(num_partitions, 0);
184902 vector<idx_t> partition_counts(num_partitions, 0);
184903 sink.total_size = sink.hash_table->GetTotalSize(partition_sizes, partition_counts, sink.max_partition_size,
184904 sink.max_partition_count);
184905 sink.probe_side_requirement =
184906 GetPartitioningSpaceRequirement(sink.context, op.types, sink.hash_table->GetRadixBits(), sink.num_threads);
184907
184908 sink.temporary_memory_state->SetMinimumReservation(sink.max_partition_size +
184909 sink.hash_table->PointerTableSize(sink.max_partition_count) +
184910 sink.probe_side_requirement);
184911 sink.temporary_memory_state->UpdateReservation(executor.context);
184912
184913 D_ASSERT(sink.temporary_memory_state->GetReservation() >= sink.probe_side_requirement);
184914 sink.hash_table->PrepareExternalFinalize(sink.temporary_memory_state->GetReservation() -
184915 sink.probe_side_requirement);
184916 sink.ScheduleFinalize(*pipeline, *this);
184917 }
Here is the call graph for this function:

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