![]() |
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.
|
JoinHashTable is a linear probing HT that is used for computing joins. More...

Classes | |
| struct | ScanStructure |
| struct | SharedState |
| struct | ProbeState |
| struct | InsertState |
| struct | ProbeSpillLocalAppendState |
| struct | ProbeSpill |
Public Types | |
| using | ValidityBytes = TemplatedValidityMask<uint8_t> |
Public Member Functions | |
| JoinHashTable (ClientContext &context, const PhysicalOperator &op, const vector< JoinCondition > &conditions, vector< LogicalType > build_types, JoinType type, const vector< idx_t > &output_columns) | |
| void | Build (PartitionedTupleDataAppendState &append_state, DataChunk &keys, DataChunk &input) |
| Add the given data to the HT. | |
| void | Merge (JoinHashTable &other) |
| Merge another HT into this one. | |
| void | Unpartition () |
| Combines the partitions in sink_collection into data_collection, as if it were not partitioned. | |
| void | AllocatePointerTable () |
| Allocate the pointer table for the probe. | |
| void | InitializePointerTable (idx_t entry_idx_from, idx_t entry_idx_to) |
| Initialize the pointer table for the probe. | |
| void | Finalize (idx_t chunk_idx_from, idx_t chunk_idx_to, bool parallel) |
| void | Probe (ScanStructure &scan_structure, DataChunk &keys, TupleDataChunkState &key_state, ProbeState &probe_state, optional_ptr< Vector > precomputed_hashes=nullptr) |
| Probe the HT with the given input chunk, resulting in the given result. | |
| void | ScanFullOuter (JoinHTScanState &state, Vector &addresses, DataChunk &result) const |
| Scan the HT to construct the full outer join result. | |
| idx_t | Count () const |
| idx_t | SizeInBytes () const |
| PartitionedTupleData & | GetSinkCollection () |
| TupleDataCollection & | GetDataCollection () |
| idx_t | ScanKeyColumn (Vector &addresses, Vector &result, idx_t column_index) const |
| bool | NullValuesAreEqual (idx_t col_idx) const |
| idx_t | GetRadixBits () const |
| idx_t | PointerTableCapacity (idx_t count) const |
| Capacity of the pointer table given the ht count. | |
| idx_t | PointerTableSize (idx_t count) const |
| Size of the pointer table (in bytes). | |
| void | SetBuildBloomFilter (const bool should_build) |
| BloomFilter & | GetBloomFilter () |
| idx_t | GetTotalSize (const vector< unique_ptr< JoinHashTable > > &local_hts, idx_t &max_partition_size, idx_t &max_partition_count) const |
| Get total size of HT if all partitions would be built. | |
| idx_t | GetTotalSize (const vector< idx_t > &partition_sizes, const vector< idx_t > &partition_counts, idx_t &max_partition_size, idx_t &max_partition_count) const |
| idx_t | GetRemainingSize () const |
| Get the remaining size of the unbuilt partitions. | |
| void | SetRepartitionRadixBits (const idx_t max_ht_size, const idx_t max_partition_size, const idx_t max_partition_count) |
| Sets number of radix bits according to the max ht size. | |
| void | InitializePartitionMasks () |
| Initialized "current_partitions" and "completed_partitions". | |
| idx_t | CurrentPartitionCount () const |
| How many partitions are currently active. | |
| idx_t | FinishedPartitionCount () const |
| How many partitions are fully done. | |
| void | Repartition (JoinHashTable &global_ht) |
| Partition this HT. | |
| void | Reset () |
| Delete blocks that belong to the current partitioned HT. | |
| bool | PrepareExternalFinalize (const idx_t max_ht_size) |
| Build HT for the next partitioned probe round. | |
| void | ProbeAndSpill (ScanStructure &scan_structure, DataChunk &probe_keys, TupleDataChunkState &key_state, ProbeState &probe_state, DataChunk &probe_chunk, ProbeSpill &probe_spill, ProbeSpillLocalAppendState &spill_state, DataChunk &spill_chunk) |
| Probe whatever we can, sink the rest into a thread-local HT. | |
Static Public Member Functions | |
| static idx_t | FillWithHTOffsets (JoinHTScanState &state, Vector &addresses) |
| Fill the pointer with all the addresses from the hashtable for full scan. | |
Public Attributes | |
| ClientContext & | context |
| const PhysicalOperator & | op |
| BufferManager & | buffer_manager |
| BufferManager. | |
| const vector< JoinCondition > & | conditions |
| The join conditions. | |
| vector< LogicalType > | equality_types |
| The types of the keys used in equality comparison. | |
| vector< LogicalType > | condition_types |
| The types of the keys. | |
| vector< LogicalType > | build_types |
| The types of all conditions. | |
| const vector< idx_t > & | output_columns |
| Positions of the columns that need to output. | |
| vector< ExpressionType > | equality_predicates |
| The comparison predicates that only contain equality predicates. | |
| vector< ExpressionType > | non_equality_predicates |
| The comparison predicates that contain non-equality predicates. | |
| vector< column_t > | equality_predicate_columns |
| The column indices of the equality predicates to be used to compare the rows. | |
| vector< column_t > | non_equality_predicate_columns |
| The column indices of the non-equality predicates to be used to compare the rows. | |
| shared_ptr< TupleDataLayout > | layout_ptr |
| Data column layout. | |
| RowMatcher | row_matcher_build |
| unique_ptr< RowMatcher > | row_matcher_probe |
| unique_ptr< RowMatcher > | row_matcher_probe_no_match_sel |
| Matches the same rows as the row_matcher, but also returns a vector for no matches. | |
| bool | needs_chain_matcher |
| Is true if there are predicates that are not equality predicates and we need to use the matchers during probing. | |
| bool | chains_longer_than_one |
| If there is more than one element in the chain, we need to scan the next elements of the chain. | |
| idx_t | capacity = DConstants::INVALID_INDEX |
| The capacity of the HT. Is the same as hash_map.GetSize() / sizeof(ht_entry_t). | |
| idx_t | entry_size |
| The size of an entry as stored in the HashTable. | |
| idx_t | tuple_size |
| The total tuple size. | |
| idx_t | pointer_offset |
| Next pointer offset in tuple, also used for the position of the hash, which then gets overwritten by the pointer. | |
| Vector | vfound |
| A constant false column for initialising right outer joins. | |
| JoinType | join_type |
| The join type of the HT. | |
| bool | finalized |
| Whether or not the HT has been finalized. | |
| bool | has_null |
| Whether or not any of the key elements contain NULL. | |
| uint64_t | bitmask = DConstants::INVALID_INDEX |
| Bitmask for getting relevant bits from the hashes to determine the position. | |
| bool | single_join_error_on_multiple_rows = true |
| Whether or not we error on multiple rows found per match in a SINGLE join. | |
| bool | insert_duplicate_keys = true |
| Whether or not to perform deduplication based on join_keys when building ht. | |
| atomic< idx_t > | total_probe_matches {0} |
| Number of probe matches. | |
| struct { | |
| mutex mj_lock | |
| vector< LogicalType > correlated_types | |
| vector< unique_ptr< Expression > > correlated_aggregates | |
| The aggregate expression nodes used by the HT. | |
| unique_ptr< GroupedAggregateHashTable > correlated_counts | |
| The HT that holds the group counts for every correlated column. | |
| DataChunk group_chunk | |
| Group chunk used for aggregating into correlated_counts. | |
| DataChunk correlated_payload | |
| Payload chunk used for aggregating into correlated_counts. | |
| DataChunk result_chunk | |
| Result chunk used for aggregating into correlated_counts. | |
| } | correlated_mark_join_info |
| double | load_factor = DEFAULT_LOAD_FACTOR |
Static Public Attributes | |
| static constexpr const idx_t | USE_SALT_THRESHOLD = 8192 |
| static constexpr const idx_t | INITIAL_RADIX_BITS = 4 |
| static constexpr double | DEFAULT_LOAD_FACTOR = 2.0 |
| For a LOAD_FACTOR of 2.0, the HT is between 25% and 50% full. | |
| static constexpr double | EXTERNAL_LOAD_FACTOR = 1.5 |
| For a LOAD_FACTOR of 1.5, the HT is between 33% and 67% full. | |
| static constexpr idx_t | MINIMUM_CAPACITY = 16384 |
| Minimum capacity of the pointer table. | |
Private Member Functions | |
| void | InitializeScanStructure (ScanStructure &scan_structure, DataChunk &keys, TupleDataChunkState &key_state, const SelectionVector *¤t_sel) |
| void | Hash (DataChunk &keys, const SelectionVector &sel, idx_t count, Vector &hashes) |
| bool | UseSalt () const |
| void | GetRowPointers (DataChunk &keys, TupleDataChunkState &key_state, ProbeState &state, Vector &hashes_v, const SelectionVector *sel, idx_t &count, Vector &pointers_result_v, SelectionVector &match_sel, bool has_sel) |
| void | InsertHashes (Vector &hashes_v, idx_t count, TupleDataChunkState &chunk_state, InsertState &insert_statebool, bool parallel) |
| Insert the given set of locations into the HT with the given set of hashes_v. | |
| idx_t | PrepareKeys (DataChunk &keys, vector< TupleDataVectorFormat > &vector_data, const SelectionVector *¤t_sel, SelectionVector &sel, bool build_side) |
| Prepares keys by filtering NULLs. | |
| JoinHashTable (const JoinHashTable &)=delete | |
| Copying not allowed. | |
Private Attributes | |
| mutex | data_lock |
| Lock for combining data_collection when merging HTs. | |
| unique_ptr< PartitionedTupleData > | sink_collection |
| Partitioned data collection that the data is sunk into when building. | |
| unique_ptr< TupleDataCollection > | data_collection |
| The DataCollection holding the main data of the hash table. | |
| AllocatedData | hash_map |
| The hash map of the HT, created after finalization. | |
| ht_entry_t * | entries = nullptr |
| vector< bool > | null_values_are_equal |
| Whether or not NULL values are considered equal in each of the comparisons. | |
| unsafe_unique_array< data_t > | dead_end |
| An empty tuple that's a "dead end", can be used to stop chains early. | |
| BloomFilter | bloom_filter |
| Whether or not to use a bloom filter will be determined by the operator. | |
| bool | should_build_bloom_filter = false |
| idx_t | radix_bits |
| The current number of radix bits used to partition. | |
| ValidityMask | current_partitions |
| Bits set to 1 for currently active partitions. | |
| ValidityMask | completed_partitions |
| Bits set to 1 for completed partitions. | |
JoinHashTable is a linear probing HT that is used for computing joins.
The JoinHashTable concatenates incoming chunks inside a linked list of data ptrs. The storage looks like this internally. [SERIALIZED ROW][NEXT POINTER] [SERIALIZED ROW][NEXT POINTER] There is a separate hash map of pointers that point into this table. This is what is used to resolve the hashes. [POINTER] [POINTER] [POINTER] The pointers are either NULL
| duckdb::JoinHashTable::JoinHashTable | ( | ClientContext & | context, |
| const PhysicalOperator & | op, | ||
| const vector< JoinCondition > & | conditions, | ||
| vector< LogicalType > | build_types, | ||
| JoinType | type, | ||
| const vector< idx_t > & | output_columns ) |
| duckdb::JoinHashTable::~JoinHashTable | ( | ) |
| void duckdb::JoinHashTable::Build | ( | PartitionedTupleDataAppendState & | append_state, |
| DataChunk & | keys, | ||
| DataChunk & | input ) |
Add the given data to the HT.

| void duckdb::JoinHashTable::Merge | ( | JoinHashTable & | other | ) |
Merge another HT into this one.

| void duckdb::JoinHashTable::Unpartition | ( | ) |
Combines the partitions in sink_collection into data_collection, as if it were not partitioned.
| void duckdb::JoinHashTable::AllocatePointerTable | ( | ) |
Allocate the pointer table for the probe.

Initialize the pointer table for the probe.
Finalize the build of the HT, constructing the actual hash table and making the HT ready for probing. Finalize must be called before any call to Probe, and after Finalize is called Build should no longer be ever called.

| void duckdb::JoinHashTable::Probe | ( | ScanStructure & | scan_structure, |
| DataChunk & | keys, | ||
| TupleDataChunkState & | key_state, | ||
| ProbeState & | probe_state, | ||
| optional_ptr< Vector > | precomputed_hashes = nullptr ) |
Probe the HT with the given input chunk, resulting in the given result.

| void duckdb::JoinHashTable::ScanFullOuter | ( | JoinHTScanState & | state, |
| Vector & | addresses, | ||
| DataChunk & | result ) const |
Scan the HT to construct the full outer join result.
|
static |
Fill the pointer with all the addresses from the hashtable for full scan.

|
inline |
|
inline |
|
inline |
|
inline |
| idx_t duckdb::JoinHashTable::ScanKeyColumn | ( | Vector & | addresses, |
| Vector & | result, | ||
| idx_t | column_index ) const |
Perform a full scan of a build column, filling the provided addresses vector and result vector. Returns the number of tuples found (can be smaller than the vector capacity).

|
inline |
|
private |
|
private |
|
inlineprivate |
|
private |
Gets a pointer to the entry in the HT for each of the hashes_v using linear probing. Will update the key_match_sel vector and the count argument to the number and position of the matches


|
private |
Insert the given set of locations into the HT with the given set of hashes_v.

|
private |
Prepares keys by filtering NULLs.


|
inline |
Capacity of the pointer table given the ht count.

Size of the pointer table (in bytes).


|
inline |
|
inline |
| idx_t duckdb::JoinHashTable::GetTotalSize | ( | const vector< unique_ptr< JoinHashTable > > & | local_hts, |
| idx_t & | max_partition_size, | ||
| idx_t & | max_partition_count ) const |
Get total size of HT if all partitions would be built.


| idx_t duckdb::JoinHashTable::GetTotalSize | ( | const vector< idx_t > & | partition_sizes, |
| const vector< idx_t > & | partition_counts, | ||
| idx_t & | max_partition_size, | ||
| idx_t & | max_partition_count ) const |
| idx_t duckdb::JoinHashTable::GetRemainingSize | ( | ) | const |
Get the remaining size of the unbuilt partitions.

| void duckdb::JoinHashTable::SetRepartitionRadixBits | ( | const idx_t | max_ht_size, |
| const idx_t | max_partition_size, | ||
| const idx_t | max_partition_count ) |
Sets number of radix bits according to the max ht size.

| void duckdb::JoinHashTable::InitializePartitionMasks | ( | ) |
Initialized "current_partitions" and "completed_partitions".


| idx_t duckdb::JoinHashTable::CurrentPartitionCount | ( | ) | const |
How many partitions are currently active.


| idx_t duckdb::JoinHashTable::FinishedPartitionCount | ( | ) | const |
How many partitions are fully done.

| void duckdb::JoinHashTable::Repartition | ( | JoinHashTable & | global_ht | ) |
Partition this HT.

| void duckdb::JoinHashTable::Reset | ( | ) |
Delete blocks that belong to the current partitioned HT.


| bool duckdb::JoinHashTable::PrepareExternalFinalize | ( | const idx_t | max_ht_size | ) |
Build HT for the next partitioned probe round.

| void duckdb::JoinHashTable::ProbeAndSpill | ( | ScanStructure & | scan_structure, |
| DataChunk & | probe_keys, | ||
| TupleDataChunkState & | key_state, | ||
| ProbeState & | probe_state, | ||
| DataChunk & | probe_chunk, | ||
| ProbeSpill & | probe_spill, | ||
| ProbeSpillLocalAppendState & | spill_state, | ||
| DataChunk & | spill_chunk ) |
Probe whatever we can, sink the rest into a thread-local HT.

|
staticconstexpr |
only compare salts with the ht entries if the capacity is larger than 8192 so that it does not fit into the CPU cache
| RowMatcher duckdb::JoinHashTable::row_matcher_build |
Matches the equal condition rows during the build phase of the hash join to prevent duplicates in a list because of hash-collisions
| unique_ptr<RowMatcher> duckdb::JoinHashTable::row_matcher_probe |
Efficiently matches the non-equi rows during the probing phase, only there if non_equality_predicates is not empty
| atomic<idx_t> duckdb::JoinHashTable::total_probe_matches {0} |
Number of probe matches.
| vector<LogicalType> duckdb::JoinHashTable::correlated_types |
The types of the duplicate eliminated columns, only used in correlated MARK JOIN for flattening ANY()/ALL() expressions