From 39db0f84d95ade3ab88c0c6bb8cd24b4ac2a58a0 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Thu, 4 May 2023 11:27:20 +0800 Subject: [PATCH] add comment --- src/Interpreters/GraceHashJoin.cpp | 11 ++++++++--- src/Interpreters/JoinUtils.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Interpreters/GraceHashJoin.cpp b/src/Interpreters/GraceHashJoin.cpp index 32801887f2b..95bb76b8373 100644 --- a/src/Interpreters/GraceHashJoin.cpp +++ b/src/Interpreters/GraceHashJoin.cpp @@ -302,7 +302,7 @@ void GraceHashJoin::initBuckets() current_bucket->startJoining(); } -bool GraceHashJoin::isSupported(const std::shared_ptr & table_join [[maybe_unused]]) +bool GraceHashJoin::isSupported(const std::shared_ptr & table_join) { bool is_asof = (table_join->strictness() == JoinStrictness::Asof); @@ -472,8 +472,10 @@ bool GraceHashJoin::alwaysReturnsEmptySet() const return hash_join_is_empty; } -IBlocksStreamPtr GraceHashJoin::getNonJoinedBlocks( - const Block & left_sample_block_ [[maybe_unused]], const Block & result_sample_block_ [[maybe_unused]], UInt64 max_block_size_ [[maybe_unused]]) const +// This is only be called for bucket[0] at present. other buckets non-joined blocks are generated in +// DelayedBlocks. +IBlocksStreamPtr +GraceHashJoin::getNonJoinedBlocks(const Block & left_sample_block_, const Block & result_sample_block_, UInt64 max_block_size_) const { return hash_join->getNonJoinedBlocks(left_sample_block_, result_sample_block_, max_block_size_); } @@ -510,6 +512,8 @@ public: do { + // When left reader finish, return non-joined blocks. + // empty block means the end of this stream. if (!is_left_reader_finished) { block = left_reader.read(); @@ -521,6 +525,7 @@ public: } if (is_left_reader_finished) { + // full/right join, non_joined_blocks != nullptr if (non_joined_blocks) { block = non_joined_blocks->next(); diff --git a/src/Interpreters/JoinUtils.cpp b/src/Interpreters/JoinUtils.cpp index 59ee86ffa18..a05b58e14a1 100644 --- a/src/Interpreters/JoinUtils.cpp +++ b/src/Interpreters/JoinUtils.cpp @@ -19,7 +19,6 @@ #include - namespace DB { @@ -865,6 +864,7 @@ Block NotJoinedBlocks::nextImpl() size_t rows_added = filler->fillColumns(columns_right); if (rows_added == 0) return {}; + addLeftColumns(result_block, rows_added); addRightColumns(result_block, columns_right); }