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);
340 bool Init()
override;
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:609
bool BuildHashTable()
Read all rows from the build input and store the rows into the in-memory hash table.
Definition: hash_join_iterator.cc:488
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: hash_join_iterator.h:353
const unique_ptr_destroy_only< RowIterator > m_build_input
Definition: hash_join_iterator.h:532
bool ReadRowFromProbeRowSavingFile()
Read a single row from the probe row saving file into the tables' record buffers.
Definition: hash_join_iterator.cc:856
bool JoinedRowPassesExtraConditions() const
Definition: hash_join_iterator.cc:1009
int ReadNextJoinedRowFromHashTable()
Read a joined row from the hash table, and see if it passes any extra conditions.
Definition: hash_join_iterator.cc:1017
State
Definition: hash_join_iterator.h:506
@ 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:358
bool ReadFirstProbeRow()
Helper function for Init().
Definition: hash_join_iterator.cc:156
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:697
std::span< AccessPath * > m_single_row_index_lookups
Definition: hash_join_iterator.h:657
Prealloced_array< HashJoinCondition, 4 > m_join_conditions
Definition: hash_join_iterator.h:554
bool m_build_iterator_has_more_rows
Definition: hash_join_iterator.h:625
HashJoinChunk m_probe_row_saving_write_file
Definition: hash_join_iterator.h:647
bool WriteProbeRowToDiskIfApplicable()
Write the last row read from the probe input out to chunk files on disk, if applicable.
Definition: hash_join_iterator.cc:964
Mem_root_array< ChunkPair > m_chunk_files_on_disk
Definition: hash_join_iterator.h:558
pack_rows::TableCollection m_probe_input_tables
Definition: hash_join_iterator.h:545
bool InitRowBuffer()
Clear the row buffer and reset all iterators pointing to it.
Definition: hash_join_iterator.cc:119
int Read() override
Read a single row.
Definition: hash_join_iterator.cc:1123
String m_temporary_row_and_join_key_buffer
Definition: hash_join_iterator.h:605
bool InitHashTable()
Helper function for Init().
Definition: hash_join_iterator.cc:182
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:344
State m_state
Definition: hash_join_iterator.h:528
void LookupProbeRowInHashTable()
Definition: hash_join_iterator.cc:911
LinkedImmutableString m_current_row
Definition: hash_join_iterator.h:539
static constexpr size_t kMaxChunks
Definition: hash_join_iterator.h:589
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:62
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:949
bool m_read_from_probe_row_saving
Definition: hash_join_iterator.h:643
uint64_t m_last_hash_table_generation
Definition: hash_join_iterator.h:530
ha_rows m_build_chunk_current_row
Definition: hash_join_iterator.h:566
HashJoinType
Definition: hash_join_iterator.h:675
@ 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:632
bool m_probe_input_batch_mode
Definition: hash_join_iterator.h:615
HashJoinType m_hash_join_type
Definition: hash_join_iterator.h:680
static constexpr uint32_t kChunkPartitioningHashSeed
Definition: hash_join_iterator.h:581
bool RejectDuplicateKeys() const
If true, reject duplicate keys in the hash table.
Definition: hash_join_iterator.h:461
bool ReadRowFromProbeChunkFile()
Read a single row from the current probe chunk file into the tables' record buffers.
Definition: hash_join_iterator.cc:813
bool m_probe_row_match_flag
Definition: hash_join_iterator.h:692
pack_rows::TableCollection m_build_input_tables
Definition: hash_join_iterator.h:546
const unique_ptr_destroy_only< RowIterator > m_probe_input
Definition: hash_join_iterator.h:533
int ChunkCount()
Definition: hash_join_iterator.h:363
ha_rows m_probe_chunk_current_row
Definition: hash_join_iterator.h:567
HashJoinChunk m_probe_row_saving_read_file
Definition: hash_join_iterator.h:648
uint64_t * m_hash_table_generation
Definition: hash_join_iterator.h:529
ha_rows m_probe_row_saving_read_file_current_row
Definition: hash_join_iterator.h:654
const double m_estimated_build_rows
Definition: hash_join_iterator.h:571
int m_current_chunk
Definition: hash_join_iterator.h:563
bool Init() override
Initialize or reinitialize the iterator.
Definition: hash_join_iterator.cc:211
const JoinType m_join_type
Definition: hash_join_iterator.h:628
bool m_allow_spill_to_disk
Definition: hash_join_iterator.h:618
bool on_disk_hash_join() const
Definition: hash_join_iterator.h:435
bool InitProbeIterator()
Prepare to read the probe iterator from the beginning, and enable batch mode if applicable.
Definition: hash_join_iterator.cc:143
void SetReadingProbeRowState()
Set the iterator state to the correct READING_ROW_FROM_PROBE_*-state.
Definition: hash_join_iterator.cc:1192
Item * m_extra_condition
Definition: hash_join_iterator.h:634
hash_join_buffer::HashJoinRowBuffer m_row_buffer
Definition: hash_join_iterator.h:551
bool InitWritingToProbeRowSavingFile()
Mark that probe row saving is enabled, and prepare the probe row saving file for writing.
Definition: hash_join_iterator.cc:1179
bool InitReadingFromProbeRowSavingFile()
Mark that we should read from the probe row saving file.
Definition: hash_join_iterator.cc:1185
bool WriteBuildTableToChunkFiles()
Write all the remaining rows from the build table input to chunk files on disk.
Definition: hash_join_iterator.cc:407
bool m_write_to_probe_row_saving
Definition: hash_join_iterator.h:639
bool ReadRowFromProbeIterator()
Read a single row from the probe iterator input into the tables' record buffers.
Definition: hash_join_iterator.cc:735
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
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:228
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
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:1141
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