1#ifndef SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
2#define SQL_ITERATORS_HASH_JOIN_ITERATOR_H_
311 double estimated_build_rows,
314 bool store_rowids,
table_map tables_to_get_rowid_for,
315 size_t max_memory_available,
316 const std::vector<HashJoinCondition> &join_conditions,
319 bool probe_input_batch_mode,
320 uint64_t *hash_table_generation);
322 bool Init()
override;
Definition: hash_join_chunk.h:67
Definition: hash_join_iterator.h:253
bool BuildHashTable()
Read all rows from the build input and store the rows into the in-memory hash table.
Definition: hash_join_iterator.cc:410
void EndPSIBatchModeIfStarted() override
Ends performance schema batch mode, if started.
Definition: hash_join_iterator.h:331
const unique_ptr_destroy_only< RowIterator > m_build_input
Definition: hash_join_iterator.h:504
bool ReadRowFromProbeRowSavingFile()
Read a single row from the probe row saving file into the tables' record buffers.
Definition: hash_join_iterator.cc:793
bool JoinedRowPassesExtraConditions() const
Definition: hash_join_iterator.cc:936
int ReadNextJoinedRowFromHashTable()
Read a joined row from the hash table, and see if it passes any extra conditions.
Definition: hash_join_iterator.cc:944
State
Definition: hash_join_iterator.h:478
@ 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:336
Prealloced_array< HashJoinCondition, 4 > m_join_conditions
Definition: hash_join_iterator.h:527
bool m_build_iterator_has_more_rows
Definition: hash_join_iterator.h:592
HashJoinChunk m_probe_row_saving_write_file
Definition: hash_join_iterator.h:614
bool WriteProbeRowToDiskIfApplicable()
Write the last row read from the probe input out to chunk files on disk, if applicable.
Definition: hash_join_iterator.cc:899
Mem_root_array< ChunkPair > m_chunk_files_on_disk
Definition: hash_join_iterator.h:531
pack_rows::TableCollection m_probe_input_tables
Definition: hash_join_iterator.h:517
bool InitRowBuffer()
Clear the row buffer and reset all iterators pointing to it.
Definition: hash_join_iterator.cc:110
int Read() override
Read a single row.
Definition: hash_join_iterator.cc:1046
String m_temporary_row_and_join_key_buffer
Definition: hash_join_iterator.h:576
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:326
State m_state
Definition: hash_join_iterator.h:500
void LookupProbeRowInHashTable()
Definition: hash_join_iterator.cc:848
LinkedImmutableString m_current_row
Definition: hash_join_iterator.h:511
static constexpr size_t kMaxChunks
Definition: hash_join_iterator.h:561
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:886
bool m_read_from_probe_row_saving
Definition: hash_join_iterator.h:610
uint64_t m_last_hash_table_generation
Definition: hash_join_iterator.h:502
ha_rows m_build_chunk_current_row
Definition: hash_join_iterator.h:548
HashJoinType
Definition: hash_join_iterator.h:639
@ 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:565
bool m_probe_input_batch_mode
Definition: hash_join_iterator.h:582
HashJoinType m_hash_join_type
Definition: hash_join_iterator.h:644
static constexpr uint32_t kChunkPartitioningHashSeed
Definition: hash_join_iterator.h:545
bool RejectDuplicateKeys() const
If true, reject duplicate keys in the hash table.
Definition: hash_join_iterator.h:433
bool ReadRowFromProbeChunkFile()
Read a single row from the current probe chunk file into the tables' record buffers.
Definition: hash_join_iterator.cc:750
bool m_probe_row_match_flag
Definition: hash_join_iterator.h:656
pack_rows::TableCollection m_build_input_tables
Definition: hash_join_iterator.h:518
const unique_ptr_destroy_only< RowIterator > m_probe_input
Definition: hash_join_iterator.h:505
int ChunkCount()
Definition: hash_join_iterator.h:341
ha_rows m_probe_chunk_current_row
Definition: hash_join_iterator.h:549
HashJoinChunk m_probe_row_saving_read_file
Definition: hash_join_iterator.h:615
uint64_t * m_hash_table_generation
Definition: hash_join_iterator.h:501
ha_rows m_probe_row_saving_read_file_current_row
Definition: hash_join_iterator.h:621
const double m_estimated_build_rows
Definition: hash_join_iterator.h:553
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, bool probe_input_batch_mode, uint64_t *hash_table_generation)
Construct a HashJoinIterator.
Definition: hash_join_iterator.cc:60
int m_current_chunk
Definition: hash_join_iterator.h:536
bool Init() override
Initialize or reinitialize the iterator.
Definition: hash_join_iterator.cc:147
const JoinType m_join_type
Definition: hash_join_iterator.h:595
bool m_allow_spill_to_disk
Definition: hash_join_iterator.h:585
bool on_disk_hash_join() const
Definition: hash_join_iterator.h:407
bool InitProbeIterator()
Prepare to read the probe iterator from the beginning, and enable batch mode if applicable.
Definition: hash_join_iterator.cc:134
const table_map m_tables_to_get_rowid_for
Definition: hash_join_iterator.h:519
void SetReadingProbeRowState()
Set the iterator state to the correct READING_ROW_FROM_PROBE_*-state.
Definition: hash_join_iterator.cc:1115
Item * m_extra_condition
Definition: hash_join_iterator.h:601
hash_join_buffer::HashJoinRowBuffer m_row_buffer
Definition: hash_join_iterator.h:524
bool InitWritingToProbeRowSavingFile()
Mark that probe row saving is enabled, and prepare the probe row saving file for writing.
Definition: hash_join_iterator.cc:1102
bool InitReadingFromProbeRowSavingFile()
Mark that we should read from the probe row saving file.
Definition: hash_join_iterator.cc:1108
bool m_write_to_probe_row_saving
Definition: hash_join_iterator.h:606
bool ReadRowFromProbeIterator()
Read a single row from the probe iterator input into the tables' record buffers.
Definition: hash_join_iterator.cc:673
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
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:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Definition: hash_join_buffer.h:119
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.
ImmutableString defines a storage format for strings that is designed to be as compact as possible,...
JoinType
Definition: join_type.h:28
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:489
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
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:49
HashJoinChunk probe_chunk
Definition: hash_join_iterator.h:50
HashJoinChunk build_chunk
Definition: hash_join_iterator.h:51