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

Public Member Functions

 HashJoinLocalSourceState (const PhysicalHashJoin &op, const HashJoinGlobalSinkState &sink, Allocator &allocator)
void ExecuteTask (HashJoinGlobalSinkState &sink, HashJoinGlobalSourceState &gstate, DataChunk &chunk)
 Do the work this thread has been assigned.
bool TaskFinished () const
 Whether this thread has finished the work it has been assigned.
void ExternalBuild (HashJoinGlobalSinkState &sink, HashJoinGlobalSourceState &gstate)
 Build, probe and scan for external hash join.
void ExternalProbe (HashJoinGlobalSinkState &sink, HashJoinGlobalSourceState &gstate, DataChunk &chunk)
void ExternalScanHT (HashJoinGlobalSinkState &sink, HashJoinGlobalSourceState &gstate, DataChunk &chunk)
Public Member Functions inherited from duckdb::LocalSourceState
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Public Attributes

HashJoinSourceStage local_stage
 The stage that this thread was assigned work for.
Vector addresses
 Vector with pointers here so we don't have to re-initialize.
idx_t build_chunk_idx_from = DConstants::INVALID_INDEX
 Chunks assigned to this thread for building the pointer table.
idx_t build_chunk_idx_to = DConstants::INVALID_INDEX
ColumnDataConsumerScanState probe_local_scan
 Local scan state for probe spill.
DataChunk lhs_probe_chunk
 Chunks for holding the scanned probe collection.
DataChunk lhs_join_keys
DataChunk lhs_output
TupleDataChunkState join_key_state
ExpressionExecutor lhs_join_key_executor
JoinHashTable::ScanStructure scan_structure
 Scan structure for the external probe.
JoinHashTable::ProbeState probe_state
bool empty_ht_probe_in_progress = false
idx_t full_outer_chunk_idx_from = DConstants::INVALID_INDEX
 Chunks assigned to this thread for a full/outer scan.
idx_t full_outer_chunk_idx_to = DConstants::INVALID_INDEX
unique_ptr< JoinHTScanState > full_outer_scan_state

Constructor & Destructor Documentation

◆ HashJoinLocalSourceState()

duckdb::HashJoinLocalSourceState::HashJoinLocalSourceState ( const PhysicalHashJoin & op,
const HashJoinGlobalSinkState & sink,
Allocator & allocator )
185623 : local_stage(HashJoinSourceStage::INIT), addresses(LogicalType::POINTER), lhs_join_key_executor(sink.context),
185624 scan_structure(*sink.hash_table, join_key_state) {
185625 auto &chunk_state = probe_local_scan.current_chunk_state;
185626 chunk_state.properties = ColumnDataScanProperties::ALLOW_ZERO_COPY;
185627
185628 lhs_probe_chunk.Initialize(allocator, sink.probe_types);
185629 lhs_join_keys.Initialize(allocator, op.condition_types);
185630 lhs_output.Initialize(allocator, op.lhs_output_columns.col_types);
185631 TupleDataCollection::InitializeChunkState(join_key_state, op.condition_types);
185632
185633 for (auto &cond : op.conditions) {
185634 lhs_join_key_executor.AddExpression(*cond.left);
185635 }
185636}
DataChunk lhs_probe_chunk
Chunks for holding the scanned probe collection.
Definition duckdb.cpp:185427
HashJoinSourceStage local_stage
The stage that this thread was assigned work for.
Definition duckdb.cpp:185416
ColumnDataConsumerScanState probe_local_scan
Local scan state for probe spill.
Definition duckdb.cpp:185425
JoinHashTable::ScanStructure scan_structure
Scan structure for the external probe.
Definition duckdb.cpp:185434
Vector addresses
Vector with pointers here so we don't have to re-initialize.
Definition duckdb.cpp:185418
void InitializeChunkState(TupleDataChunkState &chunk_state, vector< column_t > column_ids={})
Definition duckdb.cpp:125879
@ ALLOW_ZERO_COPY
Definition duckdb.hpp:18811

Member Function Documentation

◆ ExecuteTask()

void duckdb::HashJoinLocalSourceState::ExecuteTask ( HashJoinGlobalSinkState & sink,
HashJoinGlobalSourceState & gstate,
DataChunk & chunk )

Do the work this thread has been assigned.

185639 {
185640 switch (local_stage) {
185641 case HashJoinSourceStage::BUILD:
185642 ExternalBuild(sink, gstate);
185643 break;
185644 case HashJoinSourceStage::PROBE:
185645 ExternalProbe(sink, gstate, chunk);
185646 break;
185647 case HashJoinSourceStage::SCAN_HT:
185648 ExternalScanHT(sink, gstate, chunk);
185649 break;
185650 default:
185651 throw InternalException("Unexpected HashJoinSourceStage in ExecuteTask!");
185652 }
185653}
void ExternalBuild(HashJoinGlobalSinkState &sink, HashJoinGlobalSourceState &gstate)
Build, probe and scan for external hash join.
Definition duckdb.cpp:185669
Here is the call graph for this function:

◆ TaskFinished()

bool duckdb::HashJoinLocalSourceState::TaskFinished ( ) const

Whether this thread has finished the work it has been assigned.

185655 {
185656 switch (local_stage) {
185657 case HashJoinSourceStage::INIT:
185658 case HashJoinSourceStage::BUILD:
185659 return true;
185660 case HashJoinSourceStage::PROBE:
185661 return scan_structure.is_null && !empty_ht_probe_in_progress;
185662 case HashJoinSourceStage::SCAN_HT:
185663 return full_outer_scan_state == nullptr;
185664 default:
185665 throw InternalException("Unexpected HashJoinSourceStage in TaskFinished!");
185666 }
185667}
Here is the caller graph for this function:

◆ ExternalBuild()

void duckdb::HashJoinLocalSourceState::ExternalBuild ( HashJoinGlobalSinkState & sink,
HashJoinGlobalSourceState & gstate )

Build, probe and scan for external hash join.

185669 {
185670 D_ASSERT(local_stage == HashJoinSourceStage::BUILD);
185671
185672 auto &ht = *sink.hash_table;
185673 ht.Finalize(build_chunk_idx_from, build_chunk_idx_to, true);
185674
185675 auto guard = gstate.Lock();
185676 gstate.build_chunk_done += build_chunk_idx_to - build_chunk_idx_from;
185677}
idx_t build_chunk_idx_from
Chunks assigned to this thread for building the pointer table.
Definition duckdb.cpp:185421
Here is the caller graph for this function:

◆ ExternalProbe()

void duckdb::HashJoinLocalSourceState::ExternalProbe ( HashJoinGlobalSinkState & sink,
HashJoinGlobalSourceState & gstate,
DataChunk & chunk )
185680 {
185681 D_ASSERT(local_stage == HashJoinSourceStage::PROBE && sink.hash_table->finalized);
185682
185683 if (!scan_structure.is_null) {
185684 // Still have elements remaining (i.e. we got >STANDARD_VECTOR_SIZE elements in the previous probe)
185685 scan_structure.Next(lhs_join_keys, lhs_output, chunk);
185686 if (chunk.size() != 0 || !scan_structure.PointersExhausted()) {
185687 return;
185688 }
185689 }
185690
185691 if (!scan_structure.is_null || empty_ht_probe_in_progress) {
185692 // Previous probe is done
185693 scan_structure.is_null = true;
185694 empty_ht_probe_in_progress = false;
185695 sink.probe_spill->consumer->FinishChunk(probe_local_scan);
185696 auto guard = gstate.Lock();
185697 gstate.probe_chunk_done++;
185698 return;
185699 }
185700
185701 // Scan input chunk for next probe
185702 sink.probe_spill->consumer->ScanChunk(probe_local_scan, lhs_probe_chunk);
185703
185704 // Get the probe chunk columns/hashes
185705 lhs_join_keys.Reset();
185706 lhs_join_key_executor.Execute(lhs_probe_chunk, lhs_join_keys);
185707 lhs_output.ReferenceColumns(lhs_probe_chunk, sink.op.lhs_output_columns.col_idxs);
185708
185709 if (sink.hash_table->Count() == 0 && !gstate.op.EmptyResultIfRHSIsEmpty()) {
185710 gstate.op.ConstructEmptyJoinResult(sink.hash_table->join_type, sink.hash_table->has_null, lhs_output, chunk);
185711 empty_ht_probe_in_progress = true;
185712 return;
185713 }
185714
185715 // Perform the probe
185716 auto precomputed_hashes = &lhs_probe_chunk.data.back();
185717 sink.hash_table->Probe(scan_structure, lhs_join_keys, join_key_state, probe_state, precomputed_hashes);
185718 scan_structure.Next(lhs_join_keys, lhs_output, chunk);
185719}

◆ ExternalScanHT()

void duckdb::HashJoinLocalSourceState::ExternalScanHT ( HashJoinGlobalSinkState & sink,
HashJoinGlobalSourceState & gstate,
DataChunk & chunk )
185722 {
185723 D_ASSERT(local_stage == HashJoinSourceStage::SCAN_HT);
185724
185725 if (!full_outer_scan_state) {
185726 full_outer_scan_state = make_uniq<JoinHTScanState>(sink.hash_table->GetDataCollection(),
185727 full_outer_chunk_idx_from, full_outer_chunk_idx_to);
185728 }
185729 sink.hash_table->ScanFullOuter(*full_outer_scan_state, addresses, chunk);
185730
185731 if (chunk.size() == 0) {
185732 full_outer_scan_state = nullptr;
185733 auto guard = gstate.Lock();
185734 gstate.full_outer_chunk_done += full_outer_chunk_idx_to - full_outer_chunk_idx_from;
185735 }
185736}
idx_t full_outer_chunk_idx_from
Chunks assigned to this thread for a full/outer scan.
Definition duckdb.cpp:185439

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