1#ifndef SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
2#define SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
324 double estimated_build_rows,
327 bool store_rowids,
table_map tables_to_get_rowid_for,
328 size_t max_memory_available,
329 const std::vector<HashJoinCondition> &join_conditions,
333 uint64_t *hash_table_generation);
335 bool Init()
override;
Definition: hash_join_chunk.h:67
Definition: hash_join_iterator.h:263
HashJoinInput m_first_input
The first input (build or probe) to read from.
Definition: hash_join_iterator.h:599
bool BuildHashTable()
Read all rows from the build input and store the rows into the in-memory hash table.
Definition: hash_join_iterator.cc:484
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: hash_join_iterator.h:348
const unique_ptr_destroy_only< RowIterator > m_build_input
Definition: hash_join_iterator.h:521
bool ReadRowFromProbeRowSavingFile()
Read a single row from the probe row saving file into the tables' record buffers.
Definition: hash_join_iterator.cc:858
bool JoinedRowPassesExtraConditions() const
Definition: hash_join_iterator.cc:1003
int ReadNextJoinedRowFromHashTable()
Read a joined row from the hash table, and see if it passes any extra conditions.
Definition: hash_join_iterator.cc:1011
State
Definition: hash_join_iterator.h:495
@ 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
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, HashJoinInput first_input, bool probe_input_batch_mode, uint64_t *hash_table_generation)
Construct a HashJoinIterator.
Definition: hash_join_iterator.cc:60
void UnlockRow() override
Definition: hash_join_iterator.h:353
bool ReadFirstProbeRow()
Helper function for Init().
Definition: hash_join_iterator.cc:155
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:684
Prealloced_array< HashJoinCondition, 4 > m_join_conditions
Definition: hash_join_iterator.h:544
bool m_build_iterator_has_more_rows
Definition: hash_join_iterator.h:615
HashJoinChunk m_probe_row_saving_write_file
Definition: hash_join_iterator.h:637
bool WriteProbeRowToDiskIfApplicable()
Write the last row read from the probe input out to chunk files on disk, if applicable.
Definition: hash_join_iterator.cc:966
Mem_root_array< ChunkPair > m_chunk_files_on_disk
Definition: hash_join_iterator.h:548
pack_rows::TableCollection m_probe_input_tables
Definition: hash_join_iterator.h:534
bool InitRowBuffer()
Clear the row buffer and reset all iterators pointing to it.
Definition: hash_join_iterator.cc:118
int Read() override
Read a single row.
Definition: hash_join_iterator.cc:1117
String m_temporary_row_and_join_key_buffer
Definition: hash_join_iterator.h:595
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:339
State m_state
Definition: hash_join_iterator.h:517
void LookupProbeRowInHashTable()
Definition: hash_join_iterator.cc:913
LinkedImmutableString m_current_row
Definition: hash_join_iterator.h:528
static constexpr size_t kMaxChunks
Definition: hash_join_iterator.h:579
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:951
bool m_read_from_probe_row_saving
Definition: hash_join_iterator.h:633
uint64_t m_last_hash_table_generation
Definition: hash_join_iterator.h:519
ha_rows m_build_chunk_current_row
Definition: hash_join_iterator.h:556
HashJoinType
Definition: hash_join_iterator.h:662
@ 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:634
bool m_probe_input_batch_mode
Definition: hash_join_iterator.h:605
HashJoinType m_hash_join_type
Definition: hash_join_iterator.h:667
static constexpr uint32_t kChunkPartitioningHashSeed
Definition: hash_join_iterator.h:571
bool RejectDuplicateKeys() const
If true, reject duplicate keys in the hash table.
Definition: hash_join_iterator.h:450
bool ReadRowFromProbeChunkFile()
Read a single row from the current probe chunk file into the tables' record buffers.
Definition: hash_join_iterator.cc:815
bool m_probe_row_match_flag
Definition: hash_join_iterator.h:679
pack_rows::TableCollection m_build_input_tables
Definition: hash_join_iterator.h:535
const unique_ptr_destroy_only< RowIterator > m_probe_input
Definition: hash_join_iterator.h:522
int ChunkCount()
Definition: hash_join_iterator.h:358
ha_rows m_probe_chunk_current_row
Definition: hash_join_iterator.h:557
HashJoinChunk m_probe_row_saving_read_file
Definition: hash_join_iterator.h:638
uint64_t * m_hash_table_generation
Definition: hash_join_iterator.h:518
ha_rows m_probe_row_saving_read_file_current_row
Definition: hash_join_iterator.h:644
const double m_estimated_build_rows
Definition: hash_join_iterator.h:561
int m_current_chunk
Definition: hash_join_iterator.h:553
bool Init() override
Initialize or reinitialize the iterator.
Definition: hash_join_iterator.cc:211
const JoinType m_join_type
Definition: hash_join_iterator.h:618
bool m_allow_spill_to_disk
Definition: hash_join_iterator.h:608
bool on_disk_hash_join() const
Definition: hash_join_iterator.h:424
bool InitProbeIterator()
Prepare to read the probe iterator from the beginning, and enable batch mode if applicable.
Definition: hash_join_iterator.cc:142
const table_map m_tables_to_get_rowid_for
Definition: hash_join_iterator.h:536
void SetReadingProbeRowState()
Set the iterator state to the correct READING_ROW_FROM_PROBE_*-state.
Definition: hash_join_iterator.cc:1186
Item * m_extra_condition
Definition: hash_join_iterator.h:624
hash_join_buffer::HashJoinRowBuffer m_row_buffer
Definition: hash_join_iterator.h:541
bool InitWritingToProbeRowSavingFile()
Mark that probe row saving is enabled, and prepare the probe row saving file for writing.
Definition: hash_join_iterator.cc:1173
bool InitReadingFromProbeRowSavingFile()
Mark that we should read from the probe row saving file.
Definition: hash_join_iterator.cc:1179
bool m_write_to_probe_row_saving
Definition: hash_join_iterator.h:629
bool ReadRowFromProbeIterator()
Read a single row from the probe iterator input into the tables' record buffers.
Definition: hash_join_iterator.cc:737
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:426
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:93
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:256
@ 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.
Definition: hash_join_iterator.h:50
HashJoinChunk probe_chunk
Definition: hash_join_iterator.h:51
HashJoinChunk build_chunk
Definition: hash_join_iterator.h:52