1#ifndef SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
2#define SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
328 double estimated_build_rows,
331 bool store_rowids,
table_map tables_to_get_rowid_for,
332 size_t max_memory_available,
333 const std::vector<HashJoinCondition> &join_conditions,
336 std::span<AccessPath *> single_row_index_lookups,
338 uint64_t *hash_table_generation);
Definition: hash_join_chunk.h:67
Definition: hash_join_iterator.h:265
HashJoinInput m_first_input
The first input (build or probe) to read from.
Definition: hash_join_iterator.h:606
bool BuildHashTable()
Read all rows from the build input and store the rows into the in-memory hash table.
Definition: hash_join_iterator.cc:494
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: hash_join_iterator.h:346
const unique_ptr_destroy_only< RowIterator > m_build_input
Definition: hash_join_iterator.h:529
bool ReadRowFromProbeRowSavingFile()
Read a single row from the probe row saving file into the tables' record buffers.
Definition: hash_join_iterator.cc:869
bool JoinedRowPassesExtraConditions() const
Definition: hash_join_iterator.cc:1022
int ReadNextJoinedRowFromHashTable()
Read a joined row from the hash table, and see if it passes any extra conditions.
Definition: hash_join_iterator.cc:1030
State
Definition: hash_join_iterator.h:503
@ READING_FROM_HASH_TABLE
@ READING_ROW_FROM_PROBE_ROW_SAVING_FILE
@ READING_ROW_FROM_PROBE_CHUNK_FILE
@ READING_FIRST_ROW_FROM_HASH_TABLE
@ LOADING_NEXT_CHUNK_PAIR
@ READING_ROW_FROM_PROBE_ITERATOR
void UnlockRow() override
Definition: hash_join_iterator.h:351
bool ReadFirstProbeRow()
Helper function for DoInit().
Definition: hash_join_iterator.cc:157
bool m_probe_row_read
If true, a row was already read from the probe input, in order to check if that input was empty.
Definition: hash_join_iterator.h:698
std::span< AccessPath * > m_single_row_index_lookups
Definition: hash_join_iterator.h:654
Prealloced_array< HashJoinCondition, 4 > m_join_conditions
Definition: hash_join_iterator.h:551
bool m_build_iterator_has_more_rows
Definition: hash_join_iterator.h:622
HashJoinChunk m_probe_row_saving_write_file
Definition: hash_join_iterator.h:644
bool WriteProbeRowToDiskIfApplicable()
Write the last row read from the probe input out to chunk files on disk, if applicable.
Definition: hash_join_iterator.cc:977
Mem_root_array< ChunkPair > m_chunk_files_on_disk
Definition: hash_join_iterator.h:555
pack_rows::TableCollection m_probe_input_tables
Definition: hash_join_iterator.h:542
bool InitRowBuffer()
Clear the row buffer and reset all iterators pointing to it.
Definition: hash_join_iterator.cc:120
String m_temporary_row_and_join_key_buffer
Definition: hash_join_iterator.h:602
bool InitHashTable()
Helper function for DoInit().
Definition: hash_join_iterator.cc:181
void SetNullRowFlag(bool is_null_row) override
Mark the current row buffer as containing a NULL row or not, so that if you read from it and the flag...
Definition: hash_join_iterator.h:340
State m_state
Definition: hash_join_iterator.h:525
void LookupProbeRowInHashTable()
Definition: hash_join_iterator.cc:924
LinkedImmutableString m_current_row
Definition: hash_join_iterator.h:536
static constexpr size_t kMaxChunks
Definition: hash_join_iterator.h:586
HashJoinIterator(THD *thd, unique_ptr_destroy_only< RowIterator > build_input, const Prealloced_array< TABLE *, 4 > &build_input_tables, double estimated_build_rows, unique_ptr_destroy_only< RowIterator > probe_input, const Prealloced_array< TABLE *, 4 > &probe_input_tables, bool store_rowids, table_map tables_to_get_rowid_for, size_t max_memory_available, const std::vector< HashJoinCondition > &join_conditions, bool allow_spill_to_disk, JoinType join_type, const Mem_root_array< Item * > &extra_conditions, std::span< AccessPath * > single_row_index_lookups, HashJoinInput first_input, bool probe_input_batch_mode, uint64_t *hash_table_generation)
Construct a HashJoinIterator.
Definition: hash_join_iterator.cc:63
int ReadJoinedRow()
Take the next matching row from the hash table, and put the row into the build tables' record buffers...
Definition: hash_join_iterator.cc:962
bool m_read_from_probe_row_saving
Definition: hash_join_iterator.h:640
String m_cached_probe_row
If m_probe_row_read is true, the contents of the first row of m_probe_input is stored in this member.
Definition: hash_join_iterator.h:681
uint64_t m_last_hash_table_generation
Definition: hash_join_iterator.h:527
ha_rows m_build_chunk_current_row
Definition: hash_join_iterator.h:563
HashJoinType
Definition: hash_join_iterator.h:672
@ IN_MEMORY_WITH_HASH_TABLE_REFILL
bool ReadNextHashJoinChunk()
Read all rows from the next chunk file into the in-memory hash table.
Definition: hash_join_iterator.cc:638
bool m_probe_input_batch_mode
Definition: hash_join_iterator.h:612
HashJoinType m_hash_join_type
Definition: hash_join_iterator.h:677
static constexpr uint32_t kChunkPartitioningHashSeed
Definition: hash_join_iterator.h:578
bool RejectDuplicateKeys() const
If true, reject duplicate keys in the hash table.
Definition: hash_join_iterator.h:458
bool ReadRowFromProbeChunkFile()
Read a single row from the current probe chunk file into the tables' record buffers.
Definition: hash_join_iterator.cc:826
bool m_probe_row_match_flag
Definition: hash_join_iterator.h:693
pack_rows::TableCollection m_build_input_tables
Definition: hash_join_iterator.h:543
const unique_ptr_destroy_only< RowIterator > m_probe_input
Definition: hash_join_iterator.h:530
int ChunkCount()
Definition: hash_join_iterator.h:356
ha_rows m_probe_chunk_current_row
Definition: hash_join_iterator.h:564
HashJoinChunk m_probe_row_saving_read_file
Definition: hash_join_iterator.h:645
bool DoInit() override
Definition: hash_join_iterator.cc:210
uint64_t * m_hash_table_generation
Definition: hash_join_iterator.h:526
ha_rows m_probe_row_saving_read_file_current_row
Definition: hash_join_iterator.h:651
const double m_estimated_build_rows
Definition: hash_join_iterator.h:568
int m_current_chunk
Definition: hash_join_iterator.h:560
const JoinType m_join_type
Definition: hash_join_iterator.h:625
bool m_allow_spill_to_disk
Definition: hash_join_iterator.h:615
bool on_disk_hash_join() const
Definition: hash_join_iterator.h:432
bool InitProbeIterator()
Prepare to read the probe iterator from the beginning, and enable batch mode if applicable.
Definition: hash_join_iterator.cc:144
void SetReadingProbeRowState()
Set the iterator state to the correct READING_ROW_FROM_PROBE_*-state.
Definition: hash_join_iterator.cc:1205
Item * m_extra_condition
Definition: hash_join_iterator.h:631
hash_join_buffer::HashJoinRowBuffer m_row_buffer
Definition: hash_join_iterator.h:548
bool InitWritingToProbeRowSavingFile()
Mark that probe row saving is enabled, and prepare the probe row saving file for writing.
Definition: hash_join_iterator.cc:1192
bool InitReadingFromProbeRowSavingFile()
Mark that we should read from the probe row saving file.
Definition: hash_join_iterator.cc:1198
bool WriteBuildTableToChunkFiles()
Write all the remaining rows from the build table input to chunk files on disk.
Definition: hash_join_iterator.cc:413
int DoRead() override
Definition: hash_join_iterator.cc:1136
bool m_write_to_probe_row_saving
Definition: hash_join_iterator.h:636
bool ReadRowFromProbeIterator()
Read a single row from the probe iterator input into the tables' record buffers.
Definition: hash_join_iterator.cc:741
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:928
LinkedImmutableString is designed for storing rows (values) in hash join.
Definition: immutable_string.h:173
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
A context for reading through a single table using a chosen access method: index read,...
Definition: row_iterator.h:82
THD * thd() const
Definition: row_iterator.h:255
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: hash_join_buffer.h:125
A structure that contains a list of input tables for a hash join operation, BKA join operation or a s...
Definition: pack_rows.h:84
This file contains the HashJoinRowBuffer class and related functions/classes.
HashJoinInput
The two inputs that we read from when executing a hash join.
Definition: hash_join_iterator.h:258
@ kProbe
For each row from this input, we try to find a match in the hash table.
@ kBuild
We build the hash table from this input.
ImmutableString defines a storage format for strings that is designed to be as compact as possible,...
JoinType
Definition: join_type.h:28
@ ANTI
Left antijoin, i.e.
@ SEMI
Left semijoin, i.e.
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
std::unique_ptr< T, Destroy_only< T > > unique_ptr_destroy_only
std::unique_ptr, but only destroying.
Definition: my_alloc.h:480
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1217
uint64_t table_map
Definition: my_table_map.h:30
Generic routines for packing rows (possibly from multiple tables at the same time) into strings,...
join_type
Definition: sql_opt_exec_shared.h:186
Our own string classes, used pervasively throughout the executor.
Access paths are a query planning structure that correspond 1:1 to iterators, in that an access path ...
Definition: access_path.h:238
Definition: hash_join_iterator.h:52
HashJoinChunk probe_chunk
Definition: hash_join_iterator.h:53
HashJoinChunk build_chunk
Definition: hash_join_iterator.h:54